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:
Local Dev 2026-09-22 23:43:01 +02:00
parent c4dbdb25fb
commit b4ece66b4c

View file

@ -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;