fix(core): keep streamable HTTP session alive when an SSE stream writ… - #1132
Open
Lubaoshuai wants to merge 1 commit into
Open
fix(core): keep streamable HTTP session alive when an SSE stream writ…#1132Lubaoshuai wants to merge 1 commit into
Lubaoshuai wants to merge 1 commit into
Conversation
…e fails A failed write inside HttpServletStreamableMcpSessionTransport.sendMessage removed the whole McpStreamableServerSession from the provider. Any transient failure (slow or aborted client, momentary IO error) therefore made the server forget the session: the client's next POST got a 404 and client sessions surfaced 'MCP session with server terminated' (modelcontextprotocol#952). A failed write now breaks only the affected SSE stream, mirroring close(): the transport is marked closed so further sends on the dead stream are no-ops, the async context is completed behind a guard, and session removal stays with explicit DELETE handling and lifecycle events. Clients can still reopen a stream via GET with Last-Event-ID. Added servlet-mock regression tests: a failed stream write no longer evicts the session (subsequent POST is accepted), while an explicit DELETE still removes it.
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.
…e fails
A failed write inside HttpServletStreamableMcpSessionTransport.sendMessage removed the whole McpStreamableServerSession from the provider. Any transient failure (slow or aborted client, momentary IO error) therefore made the server forget the session: the client's next POST got a 404 and client sessions surfaced 'MCP session with server terminated' (#952).
A failed write now breaks only the affected SSE stream, mirroring close(): the transport is marked closed so further sends on the dead stream are no-ops, the async context is completed behind a guard, and session removal stays with explicit DELETE handling and lifecycle events. Clients can still reopen a stream via GET with Last-Event-ID.
Added servlet-mock regression tests: a failed stream write no longer evicts the session (subsequent POST is accepted), while an explicit DELETE still removes it.
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context