vitest-dev/vitest · error · Error

benchmark provider did not return a result for "${name}"

Error message

benchmark provider did not return a result for "${name}"

What it means

Thrown by `runSingle` (benchmark.ts:386) when the benchmark provider ran a single-benchmark group but returned no result whose `name` matches the registered name. After `provider.run(...)`, Vitest does `results.get(name)`; a missing entry means the provider's returned `BenchResult[]` did not include a result with that exact `name`. This usually indicates a custom provider bug or a name mismatch between registration and provider output.

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 d568f8ce37)

Solutions

  1. If using a custom provider, ensure `run()` returns exactly one `BenchResult` per registration with matching `name`.
  2. Verify the registration name and the provider's output name match exactly (case, whitespace).
  3. If using the default provider, report a Vitest bug with a reproduction (it should always return a result).

Example fix

// custom provider — before
async run(group) {
  return results.filter(r => r.name !== 'skip') // omits a name
}
// after
async run(group) {
  return group.registrations.map(reg => computeResult(reg)) // one per registration, name matched
}
Defensive patterns

Strategy: validation

Validate before calling

const byName = new Map(results.map(r => [r.name, r]))
for (const reg of group.registrations) {
  if (!byName.has(reg.name)) throw new Error(`Provider missing result for "${reg.name}"`)
}

Type guard

const hasResultForEvery = (results: { name: string }[], names: readonly string[]): boolean =>
  names.every(n => results.some(r => r.name === n))

Prevention

When it happens

Trigger: Using a custom benchmark provider whose `run()` omits the result for one of the registrations or returns results with different `name` values; the provider throws internally and returns an empty/partial array; a name transformation inside the provider changes the result name.

Common situations: Authoring/testing a custom provider that doesn't return one `BenchResult` per registration; provider filtering out a benchmark it didn't run; mismatch between `BenchmarkRegistrationInput.name` and the returned `BenchResult.name`.

Related errors


AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03). Data as JSON: /data/errors/f2e108749c78fee1.json. Report an issue: GitHub.