{"record":{"id":"509322e5e182aa47","repo":"denoland/deno","slug":"bench-failed-because-the-only-option-was-used","errorCode":null,"errorMessage":"Bench failed because the \"only\" option was used","messagePattern":"Bench failed because the \"only\" option was used","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/bench/mod.rs","lineNumber":412,"sourceCode":"\n              BenchResult::Failed(failure) => {\n                report.failed += 1;\n                report.failures.push((desc.clone(), failure));\n              }\n            };\n          }\n\n          BenchEvent::UncaughtError(origin, error) => {\n            report.failed += 1;\n            reporter.report_uncaught_error(&origin, error);\n          }\n        }\n      }\n\n      reporter.report_end(&report);\n\n      if used_only {\n        return Err(anyhow!(\n          \"Bench failed because the \\\"only\\\" option was used\",\n        ));\n      }\n\n      if report.failed > 0 {\n        return Err(anyhow!(\"Bench failed\"));\n      }\n\n      Ok(())\n    })\n  };\n\n  let (join_results, result) = future::join(join_stream, handler).await;\n\n  // propagate any errors\n  for join_result in join_results {\n    join_result??;\n  }","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/bench/mod.rs#L394-L430","documentation":"deno bench deliberately fails the entire run with this error when any benchmark was registered with the 'only' option (Bench.only(...) or { only: true }), exactly like test runners treat .only. The benchmarks still execute and are reported (reporter.report_end runs first), but the process exits non-zero so a forgotten 'only' can never silently shrink CI coverage (cli/tools/bench/mod.rs:367-415).","triggerScenarios":"Any discovered bench file calls Deno.bench('name', { only: true }, fn) or Bench.only(...); the Plan event sets plan.used_only, and after all events are consumed used_only forces the error.","commonSituations":"A developer focuses one benchmark locally with only: true and commits it; CI then fails with this message; the flag survives a refactor because removing it is easy to forget.","solutions":["Search bench files for 'only: true' and 'Bench.only(' and remove the option so all benchmarks run again","Use 'deno bench --filter=<name>' to focus a single benchmark instead of the only option","Add a pre-commit/CI grep gate for .only( in *_bench.ts files so it never reaches deno bench","Keep the focused run local and never commit the only flag"],"exampleFix":"// before\nDeno.bench('sort focus', { only: true }, () => { /* ... */ });\n// after\nDeno.bench('sort focus', () => { /* ... */ });\n// focus locally with: deno bench --filter='sort focus'","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# Gate: refuse to run deno bench while any 'only' option is present\nif grep -rnE \"\\.only\\(|only:\\s*true\" --include='*_bench.ts' --include='*.bench.ts' --include='bench.ts' .; then\n  echo 'ERROR: bench \"only\" option present - remove it before running'; exit 1;\nfi\ndeno bench \"$@\"","typeGuard":null,"tryCatchPattern":"# CI: fail with a clear message distinct from real bench failures\ndeno bench || { rc=$?; grep -q '\"only\" option' build.log && echo 'someone left bench.only in the tree'; exit $rc; }","preventionTips":["Prefer 'deno bench --filter=<name>' over the only option for focusing","Add a pre-commit hook grepping bench files for 'only: true' and '.only('","Review diffs for leftover focus flags before pushing"],"tags":["bench","testing","ci","cli"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}