From 74667b00e3a25948f3e6e7c00e683d989c39859b Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 23 Mar 2026 11:09:21 -0700 Subject: [PATCH] fix: disable Chromium sandbox on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chromium's sandbox fails when the server is spawned through the Bun→Node process chain on Windows (GitHub #276). Disable chromiumSandbox on Windows at both launch sites (headless + headed). Safe: local daemon browsing user-specified URLs, Playwright docs recommend disabling in CI/container environments. Fixes #276. Co-Authored-By: Claude Opus 4.6 (1M context) --- browse/src/browser-manager.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/browse/src/browser-manager.ts b/browse/src/browser-manager.ts index 43ce4c96..820152e3 100644 --- a/browse/src/browser-manager.ts +++ b/browse/src/browser-manager.ts @@ -62,7 +62,13 @@ export class BrowserManager { private consecutiveFailures: number = 0; async launch() { - this.browser = await chromium.launch({ headless: true }); + this.browser = await chromium.launch({ + headless: true, + // On Windows, Chromium's sandbox fails when the server is spawned through + // the Bun→Node process chain (GitHub #276). Disable it — local daemon + // browsing user-specified URLs has marginal sandbox benefit. + chromiumSandbox: process.platform !== 'win32', + }); // Chromium crash → exit with clear message this.browser.on('disconnected', () => { @@ -464,7 +470,11 @@ export class BrowserManager { // 2. Launch new headed browser (try-catch — if this fails, headless stays running) let newBrowser: Browser; try { - newBrowser = await chromium.launch({ headless: false, timeout: 15000 }); + newBrowser = await chromium.launch({ + headless: false, + timeout: 15000, + chromiumSandbox: process.platform !== 'win32', + }); } catch (err: unknown) { const msg = err instanceof Error ? err.message : String(err); return `ERROR: Cannot open headed browser — ${msg}. Headless browser still running.`;