chenglou/pretext · error · Error

Unsupported browser ${browser}; expected chrome or safari

Error message

Unsupported browser ${browser}; expected chrome or safari

What it means

Thrown by parseBrowser() in benchmark-check.ts: the selected browser (from --browser= flag, else BENCHMARK_CHECK_BROWSER env, else default 'chrome') must be exactly 'chrome' or 'safari' (case-insensitive). The benchmark harness only implements Chrome and Safari automation paths; Firefox is unsupported here (unlike accuracy-check, which has a Firefox path). Any other value throws before any work begins.

Source

Thrown at scripts/benchmark-check.ts:92

  const prefix = `--${name}=`
  const arg = process.argv.find(value => value.startsWith(prefix))
  return arg === undefined ? null : arg.slice(prefix.length)
}

function parseNumberFlag(name: string, fallback: number): number {
  const raw = parseStringFlag(name)
  if (raw === null) return fallback
  const parsed = Number.parseInt(raw, 10)
  if (!Number.isFinite(parsed)) {
    throw new Error(`Invalid value for --${name}: ${raw}`)
  }
  return parsed
}

function parseBrowser(value: string | null): BrowserKind {
  const browser = (value ?? process.env['BENCHMARK_CHECK_BROWSER'] ?? 'chrome').toLowerCase()
  if (browser !== 'chrome' && browser !== 'safari') {
    throw new Error(`Unsupported browser ${browser}; expected chrome or safari`)
  }
  return browser
}

function median(values: number[]): number {
  const sorted = [...values].sort((a, b) => a - b)
  const mid = Math.floor(sorted.length / 2)
  return sorted.length % 2 === 0 ? (sorted[mid - 1]! + sorted[mid]!) / 2 : sorted[mid]!
}

function assertSame<T>(actual: T, expected: T, context: string): void {
  if (actual === expected) return
  throw new Error(
    `Benchmark runs disagree for ${context}: expected ${String(expected)}, got ${String(actual)}`,
  )
}

function medianBenchmarkResults(

View on GitHub (pinned to ac49b09b7d)

Solutions

  1. Use --browser=chrome or --browser=safari.
  2. Unset BENCHMARK_CHECK_BROWSER if you want the 'chrome' default.
  3. For Firefox benchmarking, note it is intentionally unsupported — use accuracy-check instead or extend the harness.
  4. Double-check spelling: 'chromium' and 'google-chrome' are rejected; only 'chrome' is accepted.

Example fix

# before
BENCHMARK_CHECK_BROWSER=firefox bun run scripts/benchmark-check.ts

# after
BENCHMARK_CHECK_BROWSER=chrome bun run scripts/benchmark-check.ts
# or explicitly
bun run scripts/benchmark-check.ts --browser=safari
Defensive patterns

Strategy: validation

Validate before calling

// Validate browser selection before passing it in.
const SUPPORTED = new Set(['chrome', 'safari'])
function parseBrowser(value: string | null): BrowserKind {
  const browser = (value ?? process.env.BENCHMARK_CHECK_BROWSER ?? 'chrome').toLowerCase()
  if (!SUPPORTED.has(browser)) {
    throw new Error(`Unsupported browser ${browser}; expected chrome or safari`)
  }
  return browser as BrowserKind
}

Type guard

function isSupportedBrowser(value: string): value is 'chrome' | 'safari' {
  return value === 'chrome' || value === 'safari'
}

Prevention

When it happens

Trigger: Passing --browser=firefox, --browser=edge, --browser=chromium (note: must be exactly 'chrome'), or exporting BENCHMARK_CHECK_BROWSER=opera. The comparison is lowercased, so 'Chrome' and 'SAFARI' are accepted.

Common situations: Assuming the benchmark supports the same browsers as accuracy-check (it does not support Firefox); using 'chromium' instead of 'chrome'; leaving BENCHMARK_CHECK_BROWSER set to a value from a different tool's config.

Related errors


AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12). Data as JSON: /api/errors/2e50158a64a82569. Report an issue: GitHub.