{"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/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/bench/mod.rs#L394-L430","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nDeno.bench.only(\"fast path\", () => { /* ... */ });\n\n// after\nDeno.bench(\"fast path\", () => { /* ... */ });\n// focus from the CLI instead:\n// deno bench --filter \"fast path\"","handlingStrategy":"validation","validationCode":"// CI pre-check: fail before benches run if a focused bench is committed\nconst benchFiles = [...Deno.readDirSync(\".\")]\n  .map((e) => e.name)\n  .filter((n) => n.endsWith(\"_bench.ts\"));\nfor (const f of benchFiles) {\n  if (/\\.only\\(|only:\\s*true/.test(Deno.readTextFileSync(f))) {\n    throw new Error(`${f} contains a focused bench (.only) — remove before CI`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["bench","testing","ci","guard"],"backgroundTag":"test-only-filter-used","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}