GeezerVison is showing github.com — fix: keep stdio client reading after a malformed response by hpdkhoa · Pull Request #1158 · modelcontextprotocol/java-sdk
Conversation
hpdkhoa
commented
Oct 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
The stdio client's inbound loop stopped at the first message it could not deserialize. It then marked the transport as closing and completed the inbound stream, so the request answered by that message timed out and so did every later request on the same client, including ping.
A message that fails to deserialize no longer ends the loop. If it is a response with a usable id, the transport emits an error response for that id, so the matching request fails right away with an internal error. A line that is not JSON at all is logged and skipped.
The new test runs a server process that sends a response without jsonrpc, a response with both result and error, a line that is not JSON, and then a valid response, and checks that the two malformed responses fail their requests and the valid one still arrives.
Fixes #1157
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to change)
- Documentation update
Checklist
- I have read the MCP Documentation
- My code follows the repository's style guidelines
- New and existing tests pass locally
- I have added appropriate error handling
- I have added or updated documentation as needed
Additional context
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The stdio client's inbound loop stopped at the first message it could not
deserialize. It then marked the transport as closing and completed the
inbound stream, so the request answered by that message timed out and so
did every later request on the same client, including ping.
A message that fails to deserialize no longer ends the loop. If it is a
response with a usable id, the transport emits an error response for that
id, so the matching request fails right away with an internal error. A
line that is not JSON at all is logged and skipped.
The new test runs a server process that sends a response without jsonrpc,
a response with both result and error, a line that is not JSON, and then a
valid response, and checks that the two malformed responses fail their
requests and the valid one still arrives.
Fixes modelcontextprotocol#1157
This was referenced Oct 3, 2026
|
Hi @Kehrlann, this is the fix for #1157, where I described the scope. In short: one malformed response no longer stops the stdio client's read loop. A response-shaped line with a usable id becomes an INTERNAL_ERROR response for that id, so the waiting request fails at once, and later messages still arrive. All mcp-core tests pass. Happy to change the error code if you prefer INVALID_REQUEST or PARSE_ERROR.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.