{"record":{"id":"012bad729d0a1a50","repo":"microsoft/playwright","slug":"failed-to-launch-the-browser-process-nbrowser-log","errorCode":null,"errorMessage":"Failed to launch the browser process.\\nBrowser logs:\\n${updatedLog}","messagePattern":"Failed to launch the browser process\\.\\\\nBrowser logs:\\\\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/playwright-core/src/server/browserType.ts","lineNumber":272,"sourceCode":"      } finally {\n        clearTimeout(timer!);\n      }\n    }\n    browserProcess = {\n      onclose: undefined,\n      process: launchedProcess,\n      close: () => closeOrKill((options as any).__testHookBrowserCloseTimeout || DEFAULT_PLAYWRIGHT_TIMEOUT),\n      kill\n    };\n    try {\n      const { wsEndpoint } = await progress.race([\n        this.waitForReadyState(options, browserLogsCollector),\n        exitPromise.then(() => ({ wsEndpoint: undefined })),\n      ]);\n      if (exitPromise.isDone()) {\n        const log = helper.formatBrowserLogs(browserLogsCollector.recentLogs());\n        const updatedLog = this.doRewriteStartupLog(log);\n        throw new Error(`Failed to launch the browser process.\\nBrowser logs:\\n${updatedLog}`);\n      }\n      if (!this.supportsPipeTransport(options)) {\n        transport = await WebSocketTransport.connect(progress, wsEndpoint!);\n      } else {\n        const stdio = launchedProcess.stdio as unknown as [NodeJS.ReadableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.ReadableStream];\n        transport = new PipeTransport(stdio[3], stdio[4]);\n      }\n      return { browserProcess, artifactsDir: prepared.artifactsDir, userDataDir: prepared.userDataDir, transport, wsEndpoint };\n    } catch (error) {\n      await progress.race(closeOrKill(DEFAULT_PLAYWRIGHT_TIMEOUT).catch(() => {}));\n      throw error;\n    }\n  }\n\n  async connectOverCDP(progress: Progress, params: channels.BrowserTypeConnectOverCDPParams): Promise<Browser> {\n    throw new Error('CDP connections are only supported by Chromium');\n  }\n","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/browserType.ts#L254-L290","documentation":"Thrown in _launchProcess after the browser process exits (exitPromise.isDone()) before the ready-state/websocket endpoint is reached. The message embeds rewritten browser logs (doRewriteStartupLog) so the developer can see the actual stderr that caused the crash.","triggerScenarios":"chromium.launch/firefox.launch/webkit.launch where the process starts then immediately exits — missing shared libraries, sandbox issues, wrong architecture, headless on a display-less host without the right flags, or a corrupted binary.","commonSituations":"Running headless Chromium on a minimal Linux/CI image without 'npx playwright install-deps'. Browser upgraded but system libs not. Apple Silicon running an x64 build under Rosetta failures. Container running as root without --no-sandbox (Playwright usually adds this, but custom args can override).","solutions":["Read the embedded browser logs in the error message first — they name the real cause (e.g. 'error while loading shared libraries').","Install OS dependencies: 'npx playwright install-deps' (Linux).","Reinstall the browser: 'npx playwright install <browser>'.","If running as root in a container, ensure the bundled args include --no-sandbox or use the official Playwright Docker image.","On Apple Silicon, install the matching architecture browser build."],"exampleFix":"// before (fails on minimal Linux)\nconst b = await chromium.launch();\n// after\n// shell:\n//   npx playwright install-deps chromium\n//   npx playwright install chromium\nconst b = await chromium.launch();","handlingStrategy":"try-catch","validationCode":"import fs from 'fs';\n// Pre-flight OS check (Linux): ensure deps installable\nasync function preflightLaunch() {\n  if (process.platform === 'linux') {\n    // recommend running install-deps; cannot fully validate here\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  browser = await chromium.launch();\n} catch (e) {\n  const msg = String(e.message || e);\n  if (msg.includes('Failed to launch the browser process')) {\n    // parse embedded Browser logs; surface actionable hint\n    throw new Error('Browser failed to start. Run: npx playwright install-deps && npx playwright install chromium. Logs:\\n' + msg);\n  }\n  throw e;\n}","preventionTips":["Use the official Playwright Docker images for CI to get matching system libraries.","Run 'npx playwright install-deps' on Linux before launch.","Surface the embedded browser logs verbatim in CI output — they identify the missing library."],"tags":["launch","browser-binary","system-deps","ci"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}