fix(desktop): handle async EPIPE on process.stderr#37834
Open
kagura-agent wants to merge 1 commit into
Open
Conversation
process.stderr can emit async 'error' events with EPIPE that bypass the existing synchronous try-catch in initConsoleTransport(). This causes uncaught exception crashes when the parent terminal is closed while the desktop app is still running. Add a listener on process.stderr that catches EPIPE errors and disables the console transport, matching the existing synchronous EPIPE guard pattern. The listener self-removes after the first EPIPE to avoid stale references. Closes anomalyco#37749
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.
Issue for this PR
Closes #37749
Type of change
What does this PR do?
The desktop app crashes with an uncaught EPIPE when the parent terminal is closed while the app is still running. The existing
initConsoleTransport()wrapswriteFnin a synchronous try-catch, butprocess.stderrcan also emit async'error'events with EPIPE that bypass this guard.This adds a
process.stderr.on("error", ...)listener that:isBrokenPipe()helperlog.transports.console.level = false) and removes itselfThis extends the same pattern already used for the synchronous path —
isBrokenPipe()check + transport disable.How did you verify your code works?
Checklist