{"record":{"id":"00ac2af89bbcfdf2","repo":"denoland/deno","slug":"bench-failed","errorCode":null,"errorMessage":"Bench failed","messagePattern":"Bench failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/bench/mod.rs","lineNumber":418,"sourceCode":"          }\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  }\n\n  result??;\n\n  Ok(())\n}\n","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/bench/mod.rs#L400-L436","documentation":"The terminal 'Bench failed' error: report.failed > 0 after all bench events were consumed (cli/tools/bench/mod.rs:417-419). A benchmark body threw, a BenchResult::Failed was recorded, or an UncaughtError escaped a bench module. The specific failures were already printed by the reporter in the failures section above this message; this error only converts them into a non-zero exit code.","triggerScenarios":"A bench fn throws or an assertion inside it fails (BenchResult::Failed); an uncaught error escapes during module load or between benches (BenchEvent::UncaughtError increments report.failed); teardown code panics.","commonSituations":"Benchmarks that assert performance thresholds (noshuffle iteration counts, ops/sec floors) flaking under CI load; benches touching the network or filesystem where an operation intermittently throws; module-level code in a *_bench.ts file throwing at import time.","solutions":["Read the failures section of the bench output above the error - it names the bench and the thrown error","Fix the throwing assertion or operation inside the named benchmark","If the failure is environmental (network, tmp files), make the bench self-contained or skip it via --filter/--ignore","Run 'deno bench --filter=<name>' to iterate on just the failing benchmark"],"exampleFix":"// before: bench that can throw on transient state\nDeno.bench('db query', () => { assertQueryResult(runQuery()); });\n// after: bench guarded internally, failures asserted explicitly\nDeno.bench('db query', () => {\n  const r = runQuery();\n  if (!r.ok) throw new Error(`query failed: ${r.err}`);\n});","handlingStrategy":"try-catch","validationCode":"// Keep benches deterministic: assert explicitly instead of letting ops throw\nDeno.bench('stable-metric', () => {\n  const value = computeMetric();\n  if (!Number.isFinite(value)) throw new Error(`metric not finite: ${value}`);\n});","typeGuard":null,"tryCatchPattern":"# CI wrapper: capture the failures section for a useful annotation on red builds\ndeno bench 2>&1 | tee bench.log; rc=${PIPESTATUS[0]}\nif [ $rc -ne 0 ]; then\n  sed -n '/failures:/,$p' bench.log || true\nfi\nexit $rc","preventionTips":["Keep benchmark bodies free of network/fs/timing assertions; measure, don't assert environment","Catch expected errors inside the bench fn and fail with a descriptive message","Run 'deno bench --filter' locally on changed benches before CI"],"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"}