internal/jsonrpc2: allow EOF-side responses to drain#1067
Open
ychampion wants to merge 1 commit into
Open
Conversation
7ee61a5 to
ad43d63
Compare
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.
Read-side EOF currently marks the whole connection as shutting down before handlers for already-read calls can write their responses. For stdio servers driven by one-shot pipes, that drops responses even though stdout is still writable.
This treats
io.EOFas a read half-close for in-flight responses: EOF no longer cancels already accepted incoming requests, and response writes only reject explicit close, broken writer, or non-EOF read errors.Fixes #1061
Validation:
go test ./internal/jsonrpc2 -run TestReadEOFAllowsInFlightResponseToDrain -count=1failed withWait returned error: server is closing: EOFgo test ./internal/jsonrpc2 -run TestReadEOFAllowsInFlightResponseToDrain -count=1go test ./internal/jsonrpc2 -count=1go test ./mcp -run 'Test(Stdio|Server|Client|InMemory)' -count=1\n-go test ./...\n-go vet ./...\n-git diff --check