fix: fail orphaned streamable HTTP responses on reinit#914
Open
jstar0 wants to merge 1 commit into
Open
Conversation
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.
Summary
Fixes
tools/calland other stream-backed client requests hanging indefinitely when transparent Streamable HTTP session re-initialization aborts the SSE stream that would have delivered their response.The client now tracks request IDs whose POST returned
Acceptedor an SSE stream, clears them when a response/error arrives, and on re-initialization completes any remaining stale-session requests with an internal JSON-RPC error instead of leaving their callers waiting forever.Changes
This intentionally does not replay previously accepted requests, since
tools/callcan be side-effecting and silent replay could duplicate effects. Callers get a bounded failure and can decide whether to retry.The regression test covers a request accepted by the first session, a later
SessionExpiredresponse that triggers re-initialization, and the original accepted request completing with an MCP error instead of timing out.Verification
cargo test -p rmcp --test test_streamable_http_stale_session --features client,transport-streamable-http-client,transport-streamable-http-client-reqwest,transport-streamable-http-server -- --nocapture cargo check -p rmcp --features client,transport-streamable-http-client,transport-streamable-http-client-reqwest,transport-streamable-http-server cargo clippy -p rmcp --features client,transport-streamable-http-client,transport-streamable-http-client-reqwest --lib -- -D warnings cargo fmt --all -- --checkFixes #912