fix(client): ignore unknown SSE fields instead of erroring the stream#1051
Open
imankhadiv wants to merge 2 commits into
Open
fix(client): ignore unknown SSE fields instead of erroring the stream#1051imankhadiv wants to merge 2 commits into
imankhadiv wants to merge 2 commits into
Conversation
The SSE line parser rejected any line it did not recognize (e.g. the standard `retry:` field), throwing McpTransportException and tearing down an otherwise valid stream. Per the SSE spec, unknown fields must be ignored. Log such lines at debug and continue. Refs modelcontextprotocol#1047
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
The client SSE line parser in
ResponseSubscriberserrored the whole stream on any line it didn't recognize — e.g. the standardretry:field — throwing:Per the SSE spec, a client must ignore fields it does not recognize rather than treat them as an invalid response. This change makes the parser log unrecognized lines at
debugand continue.This addresses the "ignore unknown fields" ask in #1047. As discussed there, resumability /
retry:reconnection timing is intentionally not implemented (it is being removed in the 2026-07-28 spec).Changes
ResponseSubscribers.SseLineSubscriber: the fall-throughelsenow ignores unrecognized SSE lines instead of emittingMcpTransportException. Removed the now-unused import.Testing
ResponseSubscribersTests(2 tests): aretry:line no longer errors the stream and the event still parses; an arbitrary unknown field is ignored../mvnw test -pl mcp-core→ green.Notes
sse-retryscenario stays listed inconformance-tests/conformance-baseline.yml: this fix removes the crash, but the scenario's retry-timing check is a resumability behavior that is intentionally out of scope.Refs #1047