Streamable HTTP: drain SSE frames until the initialize response, igno… #467
+23
−10
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.
Streamable HTTP: drain SSE frames until the initialize response, ignoring early notifications to prevent handshake timeouts
Motivation and Context
The streamable HTTP transport can deliver server-sent notifications (e.g., logging or connection-established events) before the JSON‑RPC initialize response. The previous implementation read only the f
irst SSE frame and treated it as the response, which could stall initialization and cause later requests (like tools/list) to time out. This change makes the handshake resilient by waiting for the actual response.
How Has This Been Tested?
cargo test -p rmcp
).Breaking Changes
None. Behavior is more permissive and robust during initialization; other transports are unaffected.
Types of changes
Checklist
Additional context
StreamableHttpPostResponse::expect_initialized
now drains SSE frames until aServerJsonRpcMessage::Response
is received, skipping empty payloads and logging intermediate notifications with
tracing::debug
.Protocol Compliance
data
is parsed as JSON per message; the client continues draining frames until the expected response is found.