{"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/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/bench/mod.rs#L400-L436","documentation":"`deno bench` exits with this error when at least one bench reported an uncaught error (`report.failed > 0`) — the bench body threw, or the bench module failed during load/registration. The per-failure details are printed by the reporter above this final message.","triggerScenarios":"A bench function throws (assertion failure, runtime error), or a bench module raises during registration; a `BenchEvent::UncaughtError` increments the failure count and the run terminates with 'Bench failed'.","commonSituations":"Bench setup that depends on missing env vars, files, or ports; assertion helpers throwing inside bench bodies; a bench module importing something unavailable in the bench environment.","solutions":["Read the 'error:' blocks printed above the summary — they name the origin module and the error for each failed bench","Reproduce a single failing bench with `deno bench --filter <name>`","Fix the throwing setup/body (validate env/files before benching); if the module itself fails to load, run it with `deno run` to see the original stack trace"],"exampleFix":"// before\nDeno.bench(\"api\", async () => {\n  const key = Deno.env.get(\"API_KEY\")!.length; // throws if unset\n});\n\n// after\nDeno.bench(\"api\", async () => {\n  const key = Deno.env.get(\"API_KEY\");\n  if (!key) throw new Error(\"API_KEY must be set for this bench\");\n  // ...\n});","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Wrap only the environment-dependent setup of a bench in try/catch and fail with a descriptive message; let assertions inside the measured body throw so the bench is still correctly counted as failed.","preventionTips":["Validate env vars and input files in shared setup before any bench body runs","Reproduce single failures with `deno bench --filter <name>`","Run the bench module with `deno run` when load-time errors are suspected"],"tags":["bench","testing","uncaught-error"],"backgroundTag":"test-case-failed","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"}