Skip to content

fix(stdio): exit cleanly when fatal logging hits a dead pipe - #1276

Merged
dcramer merged 2 commits into
mainfrom
fix/stdio-fatal-handler-epipe
Aug 28, 2026
Merged

dcramer merged 2 commits into
mainfrom
fix/stdio-fatal-handler-epipe

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1274. When the MCP client dies and closes stderr, the old fatal handlers could throw while logging, get re-invoked forever, and leave orphaned processes spinning at 100%+ CPU.

Key Changes

  • One shared exit path for uncaught exceptions, unhandled rejections, and stdio startup failures
  • Catch logging/reporting failures so a dead stderr cannot throw inside the handler
  • Always process.exit(1), including a timeout if Sentry flush hangs

Breaking Changes

  • None

Requested by David Cramer.

--

View Junior Session [Sentry]

sentry-junior Bot and others added 2 commits August 28, 2026 18:30
When the MCP client dies and all stdio pipes break, console.error in
uncaughtException/unhandledRejection can throw EPIPE and re-enter forever.
Use a re-entrancy-safe fatal handler, swallow broken-stream errors, and
always exit even if Sentry.flush hangs.

Fixes #1274

Co-Authored-By: David Cramer <[email protected]>
Client death can close stderr before uncaughtException runs. Logging then
throws inside the handler and Node re-invokes it forever. Guard exit, catch
the log, and always process.exit even if Sentry.flush hangs.

Fixes #1274

Co-Authored-By: David Cramer <[email protected]>
@sentry-junior sentry-junior Bot changed the title fix(stdio): stop fatal handler recursion on broken stderr fix(stdio): exit cleanly when fatal logging hits a dead pipe Aug 28, 2026
@dcramer
dcramer marked this pull request as ready for review August 28, 2026 18:44
@dcramer
dcramer merged commit 2180999 into main Aug 28, 2026
20 checks passed
@dcramer
dcramer deleted the fix/stdio-fatal-handler-epipe branch August 28, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stdio server spins forever at 100%+ CPU when the client dies: uncaughtException handler re-throws EPIPE on a broken stderr

1 participant