Honor GSTACK_CHROMIUM_PATH on the headless launch and setup paths

The headed path (launchPersistentContext) already passes executablePath
from GSTACK_CHROMIUM_PATH, but the headless chromium.launch() ignored it,
so a custom Chromium was used in headed mode only. setup's
ensure_playwright_browser self-test had the same gap — it always launched
Playwright's bundled Chromium.

On NixOS the bundled chrome-headless-shell can't run (it expects
/lib64/ld-linux-x86-64.so.2, absent on a Nix filesystem), so ./setup
bails before registering sub-skills and headless browsing fails even when
GSTACK_CHROMIUM_PATH points at a working system Chromium.

Pass executablePath on the headless launch, and teach
ensure_playwright_browser to use the same binary. No-op when the env var
is unset — zero impact on normal installs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
ryanlaiwy 2026-05-21 05:08:30 +00:00
parent 029356e1f0
commit 77da206a24
2 changed files with 13 additions and 1 deletions

View File

@ -312,6 +312,12 @@ export class BrowserManager {
this.browser = await chromium.launch({
headless: useHeadless,
// Honor GSTACK_CHROMIUM_PATH on the headless launch path. The headed
// path (launchPersistentContext, below) already respects it; this keeps
// both modes consistent for custom Chromium builds — e.g. a NixOS system
// binary, where Playwright's bundled chrome-headless-shell can't run.
// No-op when the env var is unset.
...(process.env.GSTACK_CHROMIUM_PATH ? { executablePath: process.env.GSTACK_CHROMIUM_PATH } : {}),
// 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. Also disabled

8
setup
View File

@ -256,7 +256,13 @@ ensure_playwright_browser() {
else
(
cd "$SOURCE_GSTACK_DIR"
bun --eval 'import { chromium } from "playwright"; const browser = await chromium.launch(); await browser.close();'
if [ -n "$GSTACK_CHROMIUM_PATH" ]; then
# GSTACK_CHROMIUM_PATH set: verify that custom Chromium instead (e.g. a
# NixOS system binary, where Playwright's bundled Chromium can't run).
bun --eval 'import { chromium } from "playwright"; const browser = await chromium.launch({ executablePath: process.env.GSTACK_CHROMIUM_PATH, args: ["--no-sandbox"] }); await browser.close();'
else
bun --eval 'import { chromium } from "playwright"; const browser = await chromium.launch(); await browser.close();'
fi
) >/dev/null 2>&1
fi
}