fix(theseus): a dead stdout pipe should not kill the browser
Launched from a shell, the main process inherits that shell's stdout. When the shell exits the pipe breaks, and the next console.log from the add-on host raises EPIPE — which Electron reports to the user as a fatal uncaught exception, over a diagnostic line nobody was left to read.
This commit is contained in:
parent
c4dbdb25fb
commit
b4ece66b4c
1 changed files with 8 additions and 0 deletions
8
main.js
8
main.js
|
|
@ -14,6 +14,14 @@ const { spawn } = require("child_process");
|
|||
const fs = require("fs");
|
||||
const WebSocket = require("ws");
|
||||
|
||||
// A browser has no business dying because its stdout went away. Launched from
|
||||
// a shell — a dev run, a test harness — Theseus inherits that shell's pipe;
|
||||
// when the shell exits the pipe breaks, and the next console.log raises EPIPE
|
||||
// in the main process, which Electron reports as a fatal uncaught exception.
|
||||
// These streams only ever carry diagnostics, and by then nobody is reading
|
||||
// them, so a write that cannot land is not an error worth stopping for.
|
||||
for (const stream of [process.stdout, process.stderr]) stream.on("error", () => {});
|
||||
|
||||
// Packaged builds ship the resolver and tor/ as unpacked resources (they can't
|
||||
// run from inside app.asar); dev runs read them from the repo.
|
||||
const RES_DIR = app.isPackaged ? process.resourcesPath : __dirname;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue