{"record":{"id":"e95e3a2e76d46371","repo":"saadeghi/daisyui","slug":"could-not-start-the-browser-spawnerror-message","errorCode":null,"errorMessage":"Could not start the browser: ${spawnError.message}","messagePattern":"Could not start the browser: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwind-play-share/index.mjs","lineNumber":265,"sourceCode":"    if (executable) return executable\n  }\n\n  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}","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/saadeghi/daisyui/blob/42b09e637e09467aa54a813a5aea53c1179aec75/packages/tailwind-play-share/index.mjs#L247-L283","documentation":"waitForDebuggingPort polls getSpawnError(); the browser child's 'error' event handler sets spawnError when Node itself fails to spawn the process (ENOENT, EACCES, EPERM). When detected during the wait loop, it throws wrapping the spawn error message.","triggerScenarios":"The executable path was readable at discovery time but cannot actually launch: file removed between checks (race), broken symlink, missing execute bit for the spawning user, or the OS cannot execute it.","commonSituations":"Stale symlink to a browser that was upgraded away; permissions changed by a package manager post-install; cross-architecture binary on the wrong CPU.","solutions":["Re-check the executable: `ls -l` and try launching it manually.","Fix permissions: `chmod +x` on the binary.","Reinstall the browser or point --browser at a known-good binary.","Note this error is re-thrown by launchBrowser with Chrome's stderr appended (see error 38)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { access, constants } from 'node:fs/promises'\nasync function canSpawn(p) {\n  try { await access(p, constants.X_OK); return true } catch { return false }\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await launchBrowser(executable, opts)\n} catch (error) {\n  if (/Could not start the browser/.test(error.message)) {\n    // re-resolve executable, fix perms, then retry once\n  }\n  throw error\n}","preventionTips":["Confirm execute permission and a valid binary right before spawn.","Avoid symlinks that may dangle after browser upgrades.","Pin the browser path to a stable location."],"tags":["browser","subprocess","spawn","chrome"],"backgroundTag":null,"analyzedSha":"42b09e637e09467aa54a813a5aea53c1179aec75","analyzedAt":"2026-08-13T04:10:09.555Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}