fix(desktop): handle EPIPE errors on stdout/stderr to prevent crash dialog#4213
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved This is a standard Node.js defensive pattern that handles EPIPE errors on stdout/stderr to prevent crash dialogs when pipes are closed. The 6-line addition is minimal, well-understood, and doesn't affect any business logic. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Added error event listeners on
process.stdoutandprocess.stderrat the very top ofapps/desktop/src/main.ts. These listeners silently swallow EPIPE errors (broken pipe) while re-throwing all other stream errors.Why
When the desktop app is launched from a terminal or parent process with piped stdout/stderr, the pipe can close while the app is still running. Effect's consolePretty logger writes to these streams. Once the pipe is broken, every subsequent write throws EPIPE, which surfaces as an Electron "A JavaScript error occurred in the main process" crash dialog.
Checklist
Note
Low Risk
Narrow startup guard around broken-pipe writes; non-EPIPE stream errors still propagate.
Overview
Registers
errorlisteners onprocess.stdoutandprocess.stderrat the very start of the Electron main entrypoint, before any imports run.EPIPE (broken pipe) is ignored so logging to closed terminal pipes no longer surfaces as an unhandled main-process exception and the “A JavaScript error occurred in the main process” dialog. Any other stream error is still rethrown.
Reviewed by Cursor Bugbot for commit f63cfe6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Ignore EPIPE errors on stdout/stderr to prevent crash dialog in desktop app
Adds error event listeners to
process.stdoutandprocess.stderrin main.ts that silently swallow errors with codeEPIPEand rethrow all others. EPIPE errors occur when a pipe closes before all data is written and previously surfaced as unhandled exceptions, triggering a crash dialog.Macroscope summarized f63cfe6.