Conversation
File append was already best-effort. Console write was not, so a closed stdout pipe (parent gone, or a launch that inherited a pipe that later closed) raised uncaught write EPIPE from afterWriteDispatched. Electron then showed "A JavaScript error occurred in the main process". Treat stdio the same as the log file: try/catch around write, and attach error listeners so the async EPIPE event is not an uncaughtException. Signed-off-by: Michael Gannotti <michael@smfworks.com>
Collaborator
|
Thanks for raising this, seems like a miss on our part. @ckelseynv will have a look! |
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.
Outcome
A closed
stdoutpipe no longer takes down the Electron main process withwrite EPIPE/ “A JavaScript error occurred in the main process”.Bug
writeEntryalready treats log-file append as best-effort. Console outputcalled
process.stdout.writewith no handler. When PAIR is launched from aparent that later closes the pipe (or after a long sleep with a dead stdout),
Node emits
write EPIPEfromafterWriteDispatched. That is anuncaughtException;electron-log-unhandledshows the dialog.Reproduced on Linux 0.1.1: second launch against a singleton that inherited a
dead stdout.
Fix
try/catcharoundprocess.stdout.write(same shape as the file write).'error'listeners onstdout/stderrininitFileLoggerso the async EPIPE event is not uncaught.
try/catchalone does notcover that path.
Scope
In:
desktop/src/shared/utils/log.tsand a unit test.Out: launcher wrapping, asar packing, service binaries. No
services/versions.jsonbump (desktop JS only).Validation
npm run test:unit -- tests/modular/structured-log-stdout.test.ts— 2 passed.npm run typecheck— pass.node scripts/spdx-headers.mjs— 0 missing.Compatibility / security
Logging to a closed stdio is dropped, same as a failed file append. No change
to what is logged. No new dependencies.
Documentation
None. Logger contract is unchanged aside from not crashing the process.