From 774e62da9591aabb6b5d627dd62842413d13c82c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 Apr 2026 12:54:28 +0000 Subject: [PATCH 1/2] fix(mcp): replace hardcoded 30s with defaultConnectTimeout constant, fix <\= 0 guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses #3933. - Define package-level unexported constant defaultConnectTimeout = 30 * time.Second to serve as the single source of truth for the connect-timeout default in this package. - Replace inline '30 * time.Second' literals in NewHTTPConnection and reconnectSDKTransport with the named constant. - Fix inconsistent guard in reconnectSDKTransport: '== 0' → '<= 0' so that negative values (which are invalid) also fall back to the default, consistent with the guard in NewHTTPConnection. No functional change for valid inputs; negative connectTimeout values are now treated the same as zero (both → defaultConnectTimeout). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/mcp/connection.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/mcp/connection.go b/internal/mcp/connection.go index 16162dd8..e5ee4d56 100644 --- a/internal/mcp/connection.go +++ b/internal/mcp/connection.go @@ -24,6 +24,10 @@ import ( var logConn = logger.New("mcp:connection") +// defaultConnectTimeout is the fallback connect timeout used when none is specified. +// Kept in sync with config.DefaultConnectTimeout (30 s) to avoid importing the config package. +const defaultConnectTimeout = 30 * time.Second + // ContextKey for session ID type ContextKey string @@ -199,7 +203,7 @@ func NewConnection(ctx context.Context, serverID, command string, args []string, func NewHTTPConnection(ctx context.Context, serverID, url string, headers map[string]string, oidcProvider *oidc.Provider, oidcAudience string, keepAlive time.Duration, connectTimeout time.Duration) (*Connection, error) { // Apply default connect timeout when not specified if connectTimeout <= 0 { - connectTimeout = 30 * time.Second + connectTimeout = defaultConnectTimeout } logger.LogInfo("backend", "Creating HTTP MCP connection with transport fallback, url=%s, connectTimeout=%v", url, connectTimeout) ctx, cancel := context.WithCancel(ctx) @@ -379,8 +383,8 @@ func (c *Connection) reconnectSDKTransport() error { } timeout := c.connectTimeout - if timeout == 0 { - timeout = 30 * time.Second + if timeout <= 0 { + timeout = defaultConnectTimeout } connectCtx, cancel := context.WithTimeout(c.ctx, timeout) defer cancel() From 1e5db88d8c84ea9690029ed386bf03f874127ba4 Mon Sep 17 00:00:00 2001 From: Landon Cox Date: Thu, 16 Apr 2026 07:41:09 -0700 Subject: [PATCH 2/2] Update internal/mcp/connection.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- internal/mcp/connection.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/mcp/connection.go b/internal/mcp/connection.go index e5ee4d56..8ff4b35a 100644 --- a/internal/mcp/connection.go +++ b/internal/mcp/connection.go @@ -24,7 +24,8 @@ import ( var logConn = logger.New("mcp:connection") -// defaultConnectTimeout is the fallback connect timeout used when none is specified. +// defaultConnectTimeout is the fallback connect timeout used when the configured timeout +// is non-positive or otherwise invalid. // Kept in sync with config.DefaultConnectTimeout (30 s) to avoid importing the config package. const defaultConnectTimeout = 30 * time.Second