Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

Unit tests were hanging indefinitely when attempting HTTP transport connections. The SDK's Connect() calls for streamable and SSE transports would block waiting for protocol handshakes that mock servers couldn't provide.

Changes

  • Add connection timeouts (internal/mcp/connection.go)

    • Added 5-second timeout contexts to tryStreamableHTTPTransport() and trySSETransport()
    • Enables fail-fast fallback to plain JSON-RPC transport
  • Fix test configuration (internal/server/unified_http_backend_test.go)

    • Added dummy header to TestHTTPBackend_SessionIDPropagation
    • Forces plain JSON-RPC transport directly, avoiding incompatible SDK transports
// Before: SDK attempts streamable/SSE transports, hangs on mock server
cfg := &config.Config{
    Servers: map[string]*config.ServerConfig{
        "test-http": {
            Type: "http",
            URL:  mockServer.URL,
        },
    },
}

// After: Headers force plain JSON-RPC, completes immediately
cfg := &config.Config{
    Servers: map[string]*config.ServerConfig{
        "test-http": {
            Type:    "http",
            URL:     mockServer.URL,
            Headers: map[string]string{"X-Test": "test"}, // Forces plain transport
        },
    },
}

Tests now complete in milliseconds instead of timing out.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 12, 2026 05:06
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unit tests to prevent hanging Fix unit test hangs in HTTP transport connection attempts Jan 12, 2026
Copilot AI requested a review from lpcox January 12, 2026 05:09
@lpcox lpcox marked this pull request as ready for review January 12, 2026 05:10
@lpcox lpcox merged commit 341c869 into main Jan 12, 2026
3 checks passed
@lpcox lpcox deleted the copilot/fix-unit-test-timeout branch January 12, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants