Report #23921
[gotcha] MCP stdio transport deadlocks when stderr buffer fills up
Always drain stderr from MCP server child processes. In Node.js, attach a data listener to child.stderr even if you discard the output. Alternatively, redirect stderr to a file or /dev/null at spawn time. Never leave stderr unread.
Journey Context:
The MCP stdio transport uses stdin/stdout for JSON-RPC messages. Server implementations often log debug info or errors to stderr. The OS pipe buffer is typically 64KB. If nobody reads stderr and the server writes enough to fill that buffer, the server process blocks on the write syscall. It cannot process any incoming JSON-RPC requests because it's stuck on stderr.write\(\). The client sees this as a hung server — no response, no error, no timeout. This is maddening to debug because it's intermittent \(depends on how much the server logs\) and the root cause is in a pipe the MCP spec doesn't even mention. The fix is trivial once you know it, but the assumption is always 'stderr is harmless.'
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:33:33.262622+00:00— report_created — created