Repository navigation
Exit instead of spinning when orphaned or fatally errored - #36
Merged
CakeRepository merged 1 commit intoOct 19, 2026
Merged
Conversation
CakeRepository
pushed a commit
that referenced
this pull request
Oct 19, 2026
Bump version in package.json, package-lock.json, server.json and SERVER_VERSION, and cut the 5.1.0 CHANGELOG entry covering the stdio lifecycle fix for orphaned/crashed servers spinning at 100% CPU (#36, fixes #35) and the @modelcontextprotocol/client 2.2.0 dev dependency update (#34). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DuaDwBdUFraDUa7S9kfo3G
Merged
CakeRepository
added a commit
that referenced
this pull request
Oct 19, 2026
Bump version in package.json, package-lock.json, server.json and SERVER_VERSION, and cut the 5.1.0 CHANGELOG entry covering the stdio lifecycle fix for orphaned/crashed servers spinning at 100% CPU (#36, fixes #35) and the @modelcontextprotocol/client 2.2.0 dev dependency update (#34). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DuaDwBdUFraDUa7S9kfo3G
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.
Fixes #35.
Problem
The
uncaughtException/unhandledRejectionhandlers insrc/index.tslogged the error and continued running. When stdio is broken (orphaned process after the parent exits, EPIPE on every write), each logging attempt throws again, so the process enters a permanent throw→log→throw cycle at ~100% CPU instead of exiting.Observed in production on macOS/arm64: 6–10 orphaned
node ... 1password-mcpprocesses (PPID 1) at ~70–100% CPU each, ~800% CPU total, load average 88, battery drain + overheating. Sampling one orphan showed ~1291/1292 samples inuv__run_check → CheckImmediate → InternalMakeCallback → TriggerUncaughtException → FormatStackTrace— a per-tick exception loop through the log path.I reproduced the mechanism with equivalent log-and-continue handlers + broken stderr: permanent 98.8% CPU spin, PPID 1 — same signature.
Fix (
src/index.ts)uncaughtException/unhandledRejection) are logged once via a guarded reporter (logging itself can't throw out, stderr may be a broken pipe) and thenprocess.exit(1)— a supervisor can restart cleanly.stdinend/close→process.exit(0): nobody left on the other end means this server is an orphan; exit instead of idling/spinning.SIGTERM/SIGINT→ cleanprocess.exit(0), guarded against re-entry.Verification
Uncaught exception.once and exits non-zero; stdin EOF → exits 0.tests/stdio-lifecycle.test.ts(fail on old code: 1 failed / 1 passed; pass on new code: 2 passed).npm run lintclean.