You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Streamable HTTP stateless connections leave server Read goroutines after client close #1073
Serve a NewStreamableHTTPHandler with StreamableHTTPOptions{Stateless: true}. Create multiple StreamableClientTransport clients (with DisableStandaloneSSE: true and MaxRetries: -1), initialize/call a tool, then close every ClientSession and the httptest.Server.
Each completed stateless client leaves a streamableServerConn.Read goroutine alive after close. In Dockyard’s integration test, 10 concurrent clients leave 10 goroutines after a five-second teardown poll.
The stateless client has no session ID, so streamableClientConn.Close correctly skips DELETE, but the corresponding server-side connection read loop does not terminate.
Expected
Stateless request-response connections should terminate their server-side read loops after the response lifecycle completes, or the SDK should expose an explicit server shutdown/lifecycle mechanism.
Impact
This blocks strict goroutine-leak assertions when testing MCP 2026-07-28 stateless HTTP. We retained functional concurrency coverage but temporarily allow one SDK-owned goroutine per stateless request while awaiting a fix.
Hi @hurtener , can you provide more details about your set up?
Is the server side tool handler long running and still active when you close the ClientSession?
Yep. Im working on a framework in around the sdk to make it easy and repeatable the creation of mcp apps (which we use a lot in our work). having said that, i was migrating to the latest spec for a future release and profiling a test server (just a simple ping, no background jobs or real work) got that issue (that didnt happen when pointing to the stable version).
Happened just after the migration, but, i couldnt replicate it using only the SDK, so i guess its something related to how i wrap the sdk that the change between one version and the other it changed so im having that issue..
My bad, I think for the moment we can close this until i further dig on the issue. Sorry for the initial opening!
At first sight my guess is that your tool handler did not return yet when the clientSession is closed. In the current implementation Read and Write goroutine are not closed until there are outgoing/incoming requests. This could be the reason why you are noticing this leak
Activity
guglielmo-san commentedon Jul 13, 2026
Hi @hurtener , can you provide more details about your set up?
Is the server side tool handler long running and still active when you close the ClientSession?
hurtener commentedon Jul 13, 2026
Yep. Im working on a framework in around the sdk to make it easy and repeatable the creation of mcp apps (which we use a lot in our work). having said that, i was migrating to the latest spec for a future release and profiling a test server (just a simple ping, no background jobs or real work) got that issue (that didnt happen when pointing to the stable version).
Happened just after the migration, but, i couldnt replicate it using only the SDK, so i guess its something related to how i wrap the sdk that the change between one version and the other it changed so im having that issue..
My bad, I think for the moment we can close this until i further dig on the issue. Sorry for the initial opening!
guglielmo-san commentedon Jul 13, 2026
At first sight my guess is that your tool handler did not return yet when the clientSession is closed. In the current implementation Read and Write goroutine are not closed until there are outgoing/incoming requests. This could be the reason why you are noticing this leak