fix: remove stdin listeners from lifecycle guard to prevent MCP -32000 errors#237
Open
ponythewhite wants to merge 1 commit intomksglu:mainfrom
Open
fix: remove stdin listeners from lifecycle guard to prevent MCP -32000 errors#237ponythewhite wants to merge 1 commit intomksglu:mainfrom
ponythewhite wants to merge 1 commit intomksglu:mainfrom
Conversation
…0 errors The lifecycle guard's process.stdin.resume() and end/close/error listeners conflict with MCP SDK's StdioServerTransport, which also reads from stdin via readline. Transient stdin events trigger false-positive parent-death detection, causing immediate process.exit(0) and "MCP error -32000: Connection closed" on the client side. Parent death is still reliably detected via ppid polling (every 30s) and OS signal handlers (SIGTERM/SIGINT/SIGHUP). Fixes mksglu#236 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Owner
|
CI is throw error. @ponythewhite |
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.
Summary
process.stdin.resume()andend/close/errorlisteners from the lifecycle guard (src/lifecycle.ts)StdioServerTransport, which also reads fromprocess.stdinviareadlineprocess.exit(0)→ client receivesMCP error -32000: Connection closedRoot Cause
The lifecycle guard (added in #103) registers stdin listeners to detect parent death. However, in an MCP stdio transport,
StdioServerTransportis the rightful owner ofprocess.stdin. Two consumers competing for the same stream causes:process.stdin.resume()puts stdin into flowing mode before the transport is ready, risking data loss during handshakeend/close/errorlisteners fire on transient pipe events that don't indicate actual parent death, triggering immediate shutdown with no grace periodWhat's Preserved
Parent death detection remains robust via:
Test Plan
-32000: Connection closederrors during extended sessionsFixes #236
🤖 Generated with Claude Code