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:
@@ -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 } : {}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user