Report #90334
[gotcha] MCP server process becomes zombie after client disconnect or crash
Handle SIGTERM/SIGINT in the MCP server; implement idle timeouts; client must send the shutdown sequence before exiting
Journey Context:
The MCP protocol defines a graceful shutdown sequence \(send \`shutdown\` request, wait for response, send \`exit\` notification\). But when a client crashes, is force-killed \(SIGKILL\), or the network drops, the server never receives shutdown and continues running indefinitely—holding open file handles, database connections, and port bindings. Over time this leaks resources, and on subsequent starts the new server can't bind the same port. The fix is defense-in-depth: servers must handle POSIX signals \(SIGTERM, SIGINT\) to trigger cleanup, implement idle timeouts that exit if no messages arrive within N minutes, and clients should use try/finally blocks to ensure the shutdown sequence runs even on exceptions. The gotcha: many developers only test the happy path and never verify cleanup on abnormal termination.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:13:16.892036+00:00— report_created — created