oven-sh/bun · error · Error

Benchmark files must only contain /a-zA-Z0-9-_/

Error message

Benchmark files must only contain /a-zA-Z0-9-_/ ${benchmarkID} in file ${file}

What it means

Guard in the bench runner's run() generator: the benchmark ID derived from the file's basename (known extensions stripped) must match ^[a-z0-9_-]+$/i so it can be used as a stable result key. Fires when the filename contains spaces, dots, or other disallowed characters.

Solutions

  1. Rename the benchmark file to contain only letters, digits, dashes, and underscores (plus one recognized extension)
  2. Extend the extension-stripping replace chain in runner-entrypoint.js if a new extension convention is added
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at bench/snippets/runner-entrypoint.js:128 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/b01d4492e159f5f6. Report an issue: GitHub.

Appendix: source

Thrown at bench/snippets/runner-entrypoint.js:128

  NODE_NO_WARNINGS: "1",
  NODE_OPTIONS: "--no-warnings",
  BUN_DEBUG_QUIET_LOGS: "1",
  NO_COLOR: "1",
  DISABLE_COLORS: "1",
};

function* run({ cmds, file }) {
  const benchmarkID = basename(file)
    .toLowerCase()
    .replace(/\.m?js$/, "")
    .replace(/\.tsx?$/, "")
    .replace(".node", "")
    .replace(".deno", "")
    .replace(".bun", "");

  // if benchmarkID doesn't contain only words, letters or numbers or dashes or underscore, throw
  if (!/^[a-z0-9_-]+$/i.test(benchmarkID)) {
    throw new Error(
      "Benchmark files must only contain /a-zA-Z0-9-_/ " +
        JSON.stringify(benchmarkID) +
        " in file " +
        JSON.stringify(file),
    );
  }

  for (let runtime in cmds) {
    const timestamp = Date.now();
    const spawnStart = performance.now();
    var { stdout, exitCode } = spawnSync({
      cmd: cmds[runtime],
      env,
      stderr: "inherit",
      stdout: "pipe",
    });
    const spawnElapsed = performance.now() - spawnStart;
    stdout = stdout.toString();

View on GitHub (pinned to 8c5296ac45)