Report #7963
[tooling] MCP server spawned via stdio hangs indefinitely on startup or first request
Explicitly drain stderr and set stream encoding to 'utf8' with line buffering; spawn with \{ stdio: \['pipe', 'pipe', 'pipe'\] \} and immediately pipe stderr to /dev/null or a logger to prevent buffer exhaustion
Journey Context:
Node.js spawn uses independent buffers for stdout/stderr \(default 200KB\). If an MCP server logs to stderr on startup and the parent hasn't drained it, the buffer fills and the process blocks on write, causing a hang. Most tutorials show simple spawn\('node', \['server.js'\]\) without handling stdio. The fix is to either inherit stderr \(if logs are harmless\) or explicitly pipe and drain it continuously.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:14:30.916081+00:00— report_created — created