vitest-dev/vitest · error · Error
benchmark provider did not return a result for
Error message
benchmark provider did not return a result for "${name}" What it means
When `bench(name, fn).run()` executes, Vitest calls the resolved `BenchmarkProvider.run` and expects a `BenchResult[]` containing one entry whose `name` matches the registration. This error fires when the provider returns an array without an entry for that name. It indicates a custom provider contract violation (the built-in default provider always returns matching results).
Solutions
- Ensure the custom `BenchmarkProvider.run` returns exactly one `BenchResult` per `group.registrations` entry, with `result.name === registration.name`.
- If a benchmark cannot be measured, return a result entry with the matching name and a flagged-error status rather than omitting it.
- If you did not author a custom provider, this indicates a Vitest bug — file an issue with the provider name and the group registrations.
- Double-check the provider is not caching results across different benchmark groups (the cache at benchmark.ts:130 caches the provider module, not results).
Example fix
// before - custom provider
async run(group) {
return group.registrations.map(r => runBench(r)).filter(Boolean) // drops failures
}
// after
async run(group) {
return group.registrations.map(r => {
try { return makeResult(r.name, runBench(r)) }
catch (e) { return makeFailedResult(r.name, e) }
})
} Defensive patterns
Strategy: validation
Validate before calling
const results = await provider.run(group); const missing = group.registrations.filter(r => !results.some(res => res.name === r.name)); if (missing.length) throw new Error(`provider missing: ${missing.map(m => m.name).join(', ')}`) Type guard
function coversAllNames(results: BenchResult[], names: string[]): boolean { const s = new Set(results.map(r => r.name)); return names.every(n => s.has(n)) } Try / catch
try { return await runSingle(name, fn, fnOpts, options, meta, writeResult) } catch (e) { if (/did not return a result/.test(e.message)) { logProviderDiagnostics(provider, name); } throw e } Prevention
- In a custom provider, map over `group.registrations` 1:1 and always return a result per name.
- Add a provider unit test asserting `results.length === registrations.length` and name coverage.
- Never omit errored benchmarks — return a failed-result entry with the right name.
When it happens
Trigger: A custom `BenchmarkProvider.run(group)` returns results whose `.name` fields do not cover every `group.registrations[].name`. The map built at benchmark.ts:345-349 keys results by `result.name`; `runSingle` then does `results.get(name)` and throws on miss (benchmark.ts:384-386).
Common situations: Custom provider returns results keyed by a transformed name (e.g. slugified, suffixed); provider drops results for benchmarks that errored instead of returning a failed-result entry; provider returns an empty array; provider returns results for a different group due to a stale cache.
Related errors
- Benchmark provider loaded from
- Failed to load benchmark provider from
- All browser instances within a project must use the same…
- `bench.compare()` expects every argument to be the return…
- `bench.compare()` requires at least 2 benchmarks, received
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/f2e108749c78fee1.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vitest/src/runtime/benchmark.ts:386
entries,
].join('\n'),
)
}
}
}
const runSingle = async (
name: string,
fn: BenchFn,
fnOpts: BenchOptions | undefined,
options: BenchRunOptions | undefined,
meta: TaskMeta | undefined,
writeResult: string | undefined,
): Promise<BenchResult> => {
const results = await runGroup([{ name, fn, fnOpts }], options)
const result = results.get(name)
if (!result) {
throw new Error(`benchmark provider did not return a result for "${name}"`)
}
await recordBenchmark([result], groupName(options), meta ? new Map([[name, meta]]) : undefined)
if (writeResult) {
await writeResultArtifact(writeResult, result)
}
return result
}
const runFrom = async (
name: string,
source: string | BenchFromSource,
): Promise<BenchResult> => {
const data = await resolveFromSource(source)
const benchmark: TestBenchmark = {
name: test.fullTestName,
tasks: [{ ...taskFromBaseline(name, data), rank: 1 }],
}
test.benchmarks.push(benchmark)View on GitHub (pinned to 1fa9837ec2)