Skip to content

mcpclient: report why a stdio server exited when the pipe breaks first - #4

Merged
abhijitkrm merged 1 commit into
mainfrom
fix/mcp-exit-race
Oct 7, 2026
Merged

abhijitkrm merged 1 commit into
mainfrom
fix/mcp-exit-race

Conversation

@abhijitkrm

Copy link
Copy Markdown
Owner

CI on main failed after #3 in TestStdioServerThatExits: initialize: write |1: broken pipe.

A stdio MCP server that exits immediately (bad config, missing token) can break the pipe before the client has read its exit. The write error then hid the server's own stderr, which is the part that tells the operator what went wrong. Now a failed write waits up to 2s for the server to exit and reports its stderr, the same way the read path already does.

Verified with go test -race -count=30 -run TestStdioServerThatExits ./internal/mcpclient (30 of 30 passed).

Needed before tagging v0.3.0.

🤖 Generated with Claude Code

A server that exits at once (bad config, missing token) can break the
pipe before the client reads its exit; the write error then hid the
server's stderr. Wait briefly for the exit and report it, as the read
path does. Fixes TestStdioServerThatExits flaking on CI (main, 258cfcf).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@abhijitkrm
abhijitkrm merged commit 00c0777 into main Oct 7, 2026
2 checks passed
@abhijitkrm
abhijitkrm deleted the fix/mcp-exit-race branch October 7, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant