Repository navigation
fix: stop MCP dispatch after response transport failures - #63
Merged
alexshapalov merged 1 commit intoSep 22, 2026
Merged
Conversation
The serving loop ignored buffered response write failures and continued dispatching diagnostic tools after losing its output transport. Propagate flush errors immediately, including the final response at EOF. Regression coverage exercises buffered and large responses, short writes, dispatch counts, and EOF error precedence. The protocol and JSON schema are unchanged. Closes pgrundev#60
This was referenced Sep 22, 2026
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.
What and why
Closes #60.
Server.Serveignored buffered response write errors, so a broken output pipe could leave it dispatching further diagnostic tools and ultimately returning success at input EOF. Return the flush error immediately instead. The response format and normal serving behavior are unchanged.The regression uses the real read/dispatch/write loop and proves that only the first of two tool calls runs after output failure. It covers small and larger-than-buffer responses, short writes, and a final request without a trailing newline.
Verification
Verified commit:
c1325b1de0b0f90f72426788ac927f8c5a450581.a1e6561e366455756c45a16a46647f882b3b6a1c: the new regression tests fail because the error is ignored and the second handler is called.go test -race ./internal/mcp -run 'TestServe_' -count=20: passed.bash scripts/gate.sh: passed on the committed HEAD, including build, vet, pinned golangci-lint, unit tests and all six release target builds.go test -race ./...: passed.gofmt -lon changed Go files andgit diff --check: clean.Risk and rollback
The change is limited to an already-failed output transport. Callers now receive the original write error rather than false success. Successful writes and notification handling are unchanged. Reverting this commit restores the prior behavior; no migrations or dependency changes are involved.
Checklist
scripts/gate.shpasses on the committed HEAD.model.Context, JSON, or the store.