pbakaus/impeccable · error

Browser script not found at ${browserScriptPath}

Error message

Browser script not found at ${browserScriptPath}

What it means

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.

Source

Thrown at plugin/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs:201

  }

  // Read the browser detection script — reuse it instead of reimplementing
  const browserScriptPath = path.resolve(
    path.dirname(fileURLToPath(import.meta.url)),
    '..',
    '..',
    'detect-antipatterns-browser.js'
  );
  let browserScript;
  try {
    browserScript = profileStep(profile, {
      engine: 'browser',
      phase: 'setup',
      ruleId: 'read-browser-script',
      target: url,
    }, () => fs.readFileSync(browserScriptPath, 'utf-8'));
  } catch {
    throw new Error(`Browser script not found at ${browserScriptPath}`);
  }

  // CI runners (GitHub Actions Ubuntu) block unprivileged user namespaces, so
  // Chrome can't initialize its sandbox there. Disable the sandbox only when
  // running in CI; local users keep the default hardened launch.
  const launchArgs = process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox'] : [];
  const browser = externalBrowser || await profileStepAsync(profile, {
    engine: 'browser',
    phase: 'load',
    ruleId: 'launch-browser',
    target: url,
  }, () => launchBrowser(puppeteer, { headless: options?.headless ?? true, args: launchArgs }));
  const page = await profileStepAsync(profile, {
    engine: 'browser',
    phase: 'load',
    ruleId: 'new-page',
    target: url,
  }, () => browser.newPage());

View on GitHub (pinned to d14711ae3d)

Solutions

  1. Generate the bundle: `bun run build:browser`.
  2. 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.
  3. If packaging/redistributing the plugin, ensure detect-antipatterns-browser.js is included alongside the detector engines.

Example fix

# before: browser bundle missing at the printed path

# after
cd /tmp/errlookup-RbNU9j && bun run build:browser
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const browserScriptPath = path.resolve(
  path.dirname(fileURLToPath(import.meta.url)),
  '..', '..', 'detect-antipatterns-browser.js'
);
if (!fs.existsSync(browserScriptPath)) {
  throw new Error('Browser bundle missing. Run `bun run build:browser`.');
}

Try / catch

try {
  await detectUrl(url, options);
} catch (e) {
  if (String(e.message).startsWith('Browser script not found')) {
    // run the build, then retry
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13). Data as JSON: /api/errors/1800fb78e5f764a8. Report an issue: GitHub.