Repository navigation
Fix unhandled 'error' event crashes in Node.js process streams - #1929
Closed
PierrunoYT wants to merge 4 commits into
Closed
PierrunoYT wants to merge 4 commits into
PierrunoYT wants to merge 4 commits into
Conversation
Co-authored-by: PierrunoYT <[email protected]>
Co-authored-by: PierrunoYT <[email protected]>
Fix unhandled 'error' event crashes in Node.js process streams
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
This PR fixes the
node:events:496 throw er; // Unhandled 'error' event ^crash that was occurring when Node.js process streams emit error events without proper error handlers attached.Problem
When EventEmitters like
process.stdoutorprocess.stdinemit 'error' events without listeners, Node.js throws an unhandled error event causing the entire process to crash with:Root Cause
Three main sources of unhandled error events were identified:
nonInteractiveCli.ts- Only handled EPIPE errors onprocess.stdout, leaving other error types unhandleduseTerminalSize.ts- Added resize event listener toprocess.stdoutbut no error handlerSolution
Added minimal, surgical error handling:
nonInteractiveCli.ts: Now handles allprocess.stdouterrors, not just EPIPEuseTerminalSize.ts: Added error event handler alongside resize listenergemini.tsxTesting
The fix ensures graceful error handling instead of process crashes while maintaining all existing functionality.
Fixes #1.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
play.googleapis.comnode (vitest 3)(dns block)node (vitest 2)(dns block)node (vitest 1)(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.