fix(desktop): swallow EPIPE on std streams (Windows GUI launch crash)

On Windows Squirrel/GUI launches there is no attached console, so
process.stdout/stderr are dead pipes. The daemon-output console.log/error
calls failed with EPIPE and, lacking an error listener, crashed the main
process with 'A JavaScript error occurred in the main process'. Add an
error listener that ignores broken-pipe writes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Harshit Singh Bhandari 2026-06-23 01:17:21 +05:30
parent 5440d2d1df
commit a6ebabda68
No known key found for this signature in database
1 changed files with 11 additions and 0 deletions

View File

@ -36,6 +36,17 @@ import { createBrowserViewHost, type BrowserViewHost } from "./main/browser-view
declare const MAIN_WINDOW_VITE_DEV_SERVER_URL: string | undefined;
declare const MAIN_WINDOW_VITE_NAME: string;
// Windows GUI/Squirrel launches have no attached console, so process.stdout and
// process.stderr are dead pipes. The daemon-output console.log/console.error calls
// below then fail with EPIPE, and with no "error" listener that surfaces as an
// uncaught exception that crashes the main process. Swallow broken-pipe write
// errors on the std streams: a dropped log line is harmless, the crash is not.
const ignoreStdStreamError = (err: NodeJS.ErrnoException): void => {
if (err.code === "EPIPE") return;
};
process.stdout.on("error", ignoreStdStreamError);
process.stderr.on("error", ignoreStdStreamError);
// Must run before app ready so the About panel and default-menu role labels use it.
app.setName("Agent Orchestrator");