mirror of https://github.com/garrytan/gstack.git
fix(browser): add --no-sandbox for root user on Linux/WSL2
Chromium's sandbox can't initialize when running as root on Linux, causing an immediate exit. Extend the existing CI/CONTAINER check to also cover this case, keeping the Windows-safe `typeof getuid` guard.
This commit is contained in:
parent
7b4738bca0
commit
014a51bd6f
|
|
@ -182,10 +182,11 @@ export class BrowserManager {
|
|||
const launchArgs: string[] = [];
|
||||
let useHeadless = true;
|
||||
|
||||
// Docker/CI: Chromium sandbox requires unprivileged user namespaces which
|
||||
// are typically disabled in containers. Detect container environment and
|
||||
// add --no-sandbox automatically.
|
||||
if (process.env.CI || process.env.CONTAINER) {
|
||||
// Docker/CI/root: Chromium sandbox requires unprivileged user namespaces which
|
||||
// are typically disabled in containers and are never available for the root
|
||||
// user on Linux. Detect all three cases and add --no-sandbox automatically.
|
||||
const isRoot = typeof process.getuid === 'function' && process.getuid() === 0;
|
||||
if (process.env.CI || process.env.CONTAINER || isRoot) {
|
||||
launchArgs.push('--no-sandbox');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue