fix: use system Chromium on unsupported OS (Ubuntu 26.04+)

Playwright's bundled browser install fails on Ubuntu 26.04 with
"Playwright does not support chromium on ubuntu26.04-x64".

Fall back to system Chromium (/usr/bin/chromium-browser etc.) via
executablePath when launching headless, bypassing the platform check.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
kim
2026-05-01 17:45:45 +09:00
co-authored by Claude Sonnet 4.6
parent 8da045eb72
commit d4fedeccd5
+17 -2
View File
@@ -220,8 +220,23 @@ async function getOrCreateSession(sessionId: string): Promise<BrowserSession> {
if (!connected) throw new Error(`Chrome launched but did not respond on port ${debugPort} after 15s. Close any existing Chrome windows and try again.`);
console.log(`[Browser] Launched and connected to Chrome on port ${debugPort}`);
} else {
console.log('[Browser] No system Chrome found; launching Playwright Chromium directly.');
browser = await pw.chromium.launch({ headless: false });
// Fall back to Playwright's bundled Chromium, but prefer system Chromium
// when the OS isn't officially supported by Playwright (e.g. Ubuntu 26.04+).
const sysCandidates = [
'/usr/bin/chromium-browser',
'/usr/bin/chromium',
'/snap/bin/chromium',
];
const sysExec = sysCandidates.find(p => fs.existsSync(p));
if (sysExec) {
console.log(`[Browser] Using system Chromium: ${sysExec}`);
} else {
console.log('[Browser] No system Chrome found; launching Playwright Chromium directly.');
}
browser = await pw.chromium.launch({
headless: false,
...(sysExec ? { executablePath: sysExec } : {}),
});
}
}