denoland/deno · error
Bench failed because the "only" option was used
Error message
Bench failed because the "only" option was used
What it means
Deno's bench runner deliberately fails the whole `deno bench` invocation when any bench was registered with `Bench.only` (or `only: true`). Like Jest/Vitest's `.only`, this guard exists so a locally focused run can never silently pass CI. It fires after all benches have run and results were reported.
Solutions
- Search the suite for focused benches and remove them: rg '\.only\(|only:\s*true' -g '*_bench.ts'
- Use `deno bench --filter <name>` to focus a single bench instead of `.only`
- Add a CI pre-check that rejects any `.only` in bench files
Example fix
// before
Deno.bench.only("fast path", () => { /* ... */ });
// after
Deno.bench("fast path", () => { /* ... */ });
// focus from the CLI instead:
// deno bench --filter "fast path" Defensive patterns
Strategy: validation
Validate before calling
// CI pre-check: fail before benches run if a focused bench is committed
const benchFiles = [...Deno.readDirSync(".")]
.map((e) => e.name)
.filter((n) => n.endsWith("_bench.ts"));
for (const f of benchFiles) {
if (/\.only\(|only:\s*true/.test(Deno.readTextFileSync(f))) {
throw new Error(`${f} contains a focused bench (.only) — remove before CI`);
}
} Prevention
- Prefer `deno bench --filter <name>` over `.only`
- Add a CI grep that rejects `.only` in *_bench.ts files
- Review bench diffs for leftover focus markers before merging
When it happens
Trigger: A bench file calls `Deno.bench.only(name, fn)` or passes `{ only: true }` to `Deno.bench`, and `deno bench` runs to completion; the runner tracked `used_only` and exits with this error even if every executed bench passed.
Common situations: A developer focuses one bench locally with `.only`, commits the file, and CI fails at the end of the bench run despite all executed benches passing.
Related errors
- Bench failed
- No bench modules found
- BenchContext::end() has already been invoked
- codesigning requires a macOS build host (uses…
- deno ci requires a lockfile, but none was found. hint…
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/509322e5e182aa47.
Report an issue: GitHub.
Appendix: source
Thrown at cli/tools/bench/mod.rs:412
BenchResult::Failed(failure) => {
report.failed += 1;
report.failures.push((desc.clone(), failure));
}
};
}
BenchEvent::UncaughtError(origin, error) => {
report.failed += 1;
reporter.report_uncaught_error(&origin, error);
}
}
}
reporter.report_end(&report);
if used_only {
return Err(anyhow!(
"Bench failed because the \"only\" option was used",
));
}
if report.failed > 0 {
return Err(anyhow!("Bench failed"));
}
Ok(())
})
};
let (join_results, result) = future::join(join_stream, handler).await;
// propagate any errors
for join_result in join_results {
join_result??;
}View on GitHub (pinned to 9ad36f7a2c)