fix: disable Chromium sandbox on Windows

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) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-03-23 11:09:21 -07:00
parent ee1c0c109e
commit 74667b00e3
+12 -2
View File
@@ -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.`;