{"id":"c111ad1edd9207ce","repo":"vitest-dev/vitest","slug":"some-benchmarks-failed","errorCode":null,"errorMessage":"Some benchmarks failed","messagePattern":"Some benchmarks failed","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/benchmark/default-provider.ts","lineNumber":38,"sourceCode":"        signal: test.context.signal,\n        name: `${test.fullTestName} ${currentIndex}`,\n        retainSamples: config.benchmark.retainSamples,\n        ...options,\n        now,\n      })\n      for (const { name, fn, fnOpts } of registrations) {\n        tinybench.add(name, fn, fnOpts)\n      }\n      await tinybench.run()\n\n      const errors = tinybench.tasks\n        .filter(task => task.result.state === 'errored')\n        .map(task => (task.result as { error: unknown }).error)\n      if (errors.length === 1) {\n        throw errors[0]\n      }\n      if (errors.length > 1) {\n        throw new AggregateError(errors, 'Some benchmarks failed')\n      }\n\n      return tinybench.tasks.map(toBenchResult)\n    },\n  }\n}\n\nfunction toBenchResult(task: TinybenchTask): BenchResult {\n  const result = task.result\n  if (result.state !== 'completed') {\n    throw new Error(`task \"${task.name}\" did not complete: received \"${result.state}\"`)\n  }\n  return {\n    ...result,\n    name: task.name,\n  }\n}\n","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/runtime/benchmark/default-provider.ts#L20-L56","documentation":"The default tinybench-backed provider collects every task's error after a run. If exactly one task errored, that error is rethrown directly; if TWO or more errored, they're wrapped in an `AggregateError` with message `\"Some benchmarks failed\"` (see `default-provider.ts:38`). The individual causes live on `error.errors`. This surfaces from `bench().run()` or `bench.compare()` when multiple benchmark bodies throw.","triggerScenarios":"Two or more `bench()` functions in the same test throwing; a shared setup bug breaking every benchmark in a `compare`.","commonSituations":"A missing import/fixture referenced by several benchmarks; a code change that broke multiple benchmarked functions at once; an environment issue (missing env var) hitting all benchmarks.","solutions":["Inspect `error.errors` (the AggregateError's array) to see each individual failure and stack.","Fix the first/root underlying error — often a shared dependency.","Temporarily isolate benchmarks (comment out others) to pinpoint which threw."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate shared setup/inputs before the benchmark run so individual\n// benches don't all fail on the same missing dependency.\nfunction assertBenchDeps(deps: Record<string, unknown>) {\n  for (const [k, v] of Object.entries(deps)) {\n    if (v == null) throw new Error(`Benchmark dependency missing: ${k}`)\n  }\n}\nassertBench({ sortFn, dataset })","typeGuard":null,"tryCatchPattern":"try {\n  await bench.compare(a, b, c)\n} catch (e) {\n  if (e instanceof AggregateError) {\n    for (const inner of e.errors) console.error(inner)\n  }\n  throw e\n}","preventionTips":["Validate shared setup and dependencies before the benchmark run.","Run new benchmarks in isolation first to confirm each passes before combining.","Log AggregateError.errors to see every individual failure."],"tags":["benchmark","runtime","aggregate-error","tinybench"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}