{"record":{"id":"1800fb78e5f764a8","repo":"pbakaus/impeccable","slug":"browser-script-not-found-at-browserscriptpath-1800fb","errorCode":null,"errorMessage":"Browser script not found at ${browserScriptPath}","messagePattern":"Browser script not found at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs","lineNumber":201,"sourceCode":"  }\n\n  // Read the browser detection script — reuse it instead of reimplementing\n  const browserScriptPath = path.resolve(\n    path.dirname(fileURLToPath(import.meta.url)),\n    '..',\n    '..',\n    'detect-antipatterns-browser.js'\n  );\n  let browserScript;\n  try {\n    browserScript = profileStep(profile, {\n      engine: 'browser',\n      phase: 'setup',\n      ruleId: 'read-browser-script',\n      target: url,\n    }, () => fs.readFileSync(browserScriptPath, 'utf-8'));\n  } catch {\n    throw new Error(`Browser script not found at ${browserScriptPath}`);\n  }\n\n  // CI runners (GitHub Actions Ubuntu) block unprivileged user namespaces, so\n  // Chrome can't initialize its sandbox there. Disable the sandbox only when\n  // running in CI; local users keep the default hardened launch.\n  const launchArgs = process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox'] : [];\n  const browser = externalBrowser || await profileStepAsync(profile, {\n    engine: 'browser',\n    phase: 'load',\n    ruleId: 'launch-browser',\n    target: url,\n  }, () => launchBrowser(puppeteer, { headless: options?.headless ?? true, args: launchArgs }));\n  const page = await profileStepAsync(profile, {\n    engine: 'browser',\n    phase: 'load',\n    ruleId: 'new-page',\n    target: url,\n  }, () => browser.newPage());","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/plugin/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs#L183-L219","documentation":"After launching the browser, the URL engine reads the generated in-page detection bundle (`detect-antipatterns-browser.js`) from a path resolved relative to the engine file. That bundle is a build artifact produced by `bun run build:browser`, not hand-authored source. If readFileSync throws (file missing or unreadable), the catch converts it to this error naming the exact path it tried.","triggerScenarios":"Running the URL detector from a source tree or plugin install where `detect-antipatterns-browser.js` was never generated or was not copied next to the engine; a partial/corrupted install that shipped detect-url.mjs without its sibling bundle.","commonSituations":"Development checkout where `bun run build:browser` has not been run; a plugin distribution assembled without the browser bundle; running the engine from a moved/copied location that breaks the relative `../../detect-antipatterns-browser.js` resolution.","solutions":["Generate the bundle: `bun run build:browser`.","Verify the file exists at the printed path (the error includes the absolute browserScriptPath) and re-run a full `bun run build` if the install is partial.","If packaging/redistributing the plugin, ensure detect-antipatterns-browser.js is included alongside the detector engines."],"exampleFix":"# before: browser bundle missing at the printed path\n\n# after\ncd /tmp/errlookup-RbNU9j && bun run build:browser","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst browserScriptPath = path.resolve(\n  path.dirname(fileURLToPath(import.meta.url)),\n  '..', '..', 'detect-antipatterns-browser.js'\n);\nif (!fs.existsSync(browserScriptPath)) {\n  throw new Error('Browser bundle missing. Run `bun run build:browser`.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await detectUrl(url, options);\n} catch (e) {\n  if (String(e.message).startsWith('Browser script not found')) {\n    // run the build, then retry\n  } else throw e;\n}","preventionTips":["Run `bun run build:browser` (or full `bun run build`) before exercising the URL engine in a dev checkout.","When packaging the plugin, include detect-antipatterns-browser.js next to the engine files.","Treat a missing browser bundle as a build/install defect, not a runtime recoverable state."],"tags":["filesystem","build","browser"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}