{"record":{"id":"62d5092a3c622d89","repo":"saadeghi/daisyui","slug":"browser-exited-before-starting-exit-code-browse","errorCode":null,"errorMessage":"Browser exited before starting (exit code ${browserProcess.exitCode})","messagePattern":"Browser exited before starting \\(exit code (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwind-play-share/index.mjs","lineNumber":268,"sourceCode":"  throw new Error(\n    \"Chrome or Chromium was not found. Set TAILWIND_PLAY_BROWSER or pass --browser <path>.\",\n  )\n}\n\nconst delay = (milliseconds) =>\n  new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds))\n\nasync function waitForDebuggingPort(profileDirectory, browserProcess, timeoutMs, getSpawnError) {\n  const activePortFile = join(profileDirectory, \"DevToolsActivePort\")\n  const deadline = Date.now() + timeoutMs\n\n  while (Date.now() < deadline) {\n    const spawnError = getSpawnError()\n    if (spawnError) {\n      throw new Error(`Could not start the browser: ${spawnError.message}`)\n    }\n    if (browserProcess.exitCode !== null) {\n      throw new Error(`Browser exited before starting (exit code ${browserProcess.exitCode})`)\n    }\n\n    try {\n      const [portText] = (await readFile(activePortFile, \"utf8\")).trim().split(/\\r?\\n/)\n      const port = Number(portText)\n      if (Number.isInteger(port) && port > 0) return port\n    } catch {\n      // Chrome creates this file after its DevTools server is ready.\n    }\n\n    await delay(50)\n  }\n\n  throw new Error(\"Timed out while starting Chrome's DevTools server\")\n}\n\nasync function launchBrowser(executable, { headed, profileDirectory, timeoutMs }) {\n  const args = [","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/saadeghi/daisyui/blob/42b09e637e09467aa54a813a5aea53c1179aec75/packages/tailwind-play-share/index.mjs#L250-L286","documentation":"During the DevTools-port wait, if browserProcess.exitCode becomes non-null (process exited) before the DevToolsActivePort file appears, the script throws with that exit code. This means Chrome started then crashed/closed on its own.","triggerScenarios":"Chrome exits at startup due to bad flags, missing shared libraries, profile-directory permission errors, or sandbox restrictions.","commonSituations":"Missing system libs (libnss, libatk, libgbm) on Linux; read-only temp directory; Chrome version that rejects a flag combination used here; sandbox refusal on certain kernels.","solutions":["Read the stderr included by the launchBrowser wrapper (error 38) for Chrome's own message.","Install missing shared libraries for Chrome/Chromium.","Try a headed run (--headed) to observe startup.","Ensure the temp directory is writable and not mounted noexec."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await launchBrowser(executable, opts)\n} catch (error) {\n  if (/Browser exited before starting/.test(error.message)) {\n    // read stderr (second line of error.message) for Chrome's own reason\n  }\n  throw error\n}","preventionTips":["Install Chrome's runtime dependencies (libnss, libatk, libgbm) on Linux.","Ensure the temp/profile directory is writable and not noexec.","Try --headed once to see Chrome's startup error directly."],"tags":["browser","subprocess","chrome","crash"],"backgroundTag":null,"analyzedSha":"42b09e637e09467aa54a813a5aea53c1179aec75","analyzedAt":"2026-08-13T04:10:09.555Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}