Repository navigation
fix(serve-http): release legacy sessions whose client stream closed - #408
Merged
Merged
Conversation
Streamable HTTP clients built on the MCP SDK keep a standalone GET/SSE stream open for their whole life but rarely send DELETE /mcp when they exit, so their sessions lingered until the 12 h idle timeout. A session is now closed when its last SSE stream has been closed for MEMORIX_SESSION_DISCONNECT_GRACE_MS (default 2 min, 0 disables) and the client sent no request since. Sessions that never open a GET stream and clients that keep posting without a stream still follow the idle timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Integrated in #411 with original contributor commits retained. Added regression coverage and fixes for timer overflow, queued/running POST protection, late close events after cleanup, and the ordering where a rejected concurrent GET finishes after the real SSE stream closes. Built production-host smoke passes for silent disconnect expiry, reconnection, open SSE, POST-only sessions, and POST activity after close. The same smoke now runs on all three desktop CI platforms. Included in 1.10.5. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch:
fix/http-session-disconnect-grace→mainProblem
MCP SDK clients can open a standalone
GET /mcpSSE stream afternotifications/initializedand reconnect if that stream drops. A client thatexits without sending
DELETE /mcpleaves its legacy session open until theidle timeout, which defaults to 12 hours. The session counts against
MEMORIX_MAX_HTTP_SESSIONSduring that time.MCP session management
On a Windows workstation running several Claude Code windows,
/healthreported 22–23 active sessions, but only 5 TCP connections were still
established, one per live client process.
Change
http-session-stream-watch.tstracks the GET streams of each session.these hold:
MEMORIX_SESSION_DISCONNECT_GRACE_MS(default 120 000 ms;0disables);expireSession()helper.Tests
tests/cli/http-session-stream-watch.test.tshas 10 unit tests with faketimers: reconnect within grace, activity after close, refused GET, concurrent
streams, already-closed session, forget/dispose, disabled.
3 s grace window and the SDK
StreamableHTTPClientTransport:404"expired"(the same script on 1.10.4 still gets
200);The 12 failures were in the
codegraph,context,identity,long-term, andpurgeCLI suites. A baseline run of those five suiteson unmodified
mainproduced 12 failures out of 36 tests, across four ofthe five suites. The reported errors included subprocess timeouts and an
ENOENT.