{"id":"f2e108749c78fee1","repo":"vitest-dev/vitest","slug":"benchmark-provider-did-not-return-a-result-for","errorCode":null,"errorMessage":"benchmark provider did not return a result for \"${name}\"","messagePattern":"benchmark provider did not return a result for \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/benchmark.ts","lineNumber":386,"sourceCode":"            entries,\n          ].join('\\n'),\n        )\n      }\n    }\n  }\n\n  const runSingle = async (\n    name: string,\n    fn: BenchFn,\n    fnOpts: BenchOptions | undefined,\n    options: BenchRunOptions | undefined,\n    meta: TaskMeta | undefined,\n    writeResult: string | undefined,\n  ): Promise<BenchResult> => {\n    const results = await runGroup([{ name, fn, fnOpts }], options)\n    const result = results.get(name)\n    if (!result) {\n      throw new Error(`benchmark provider did not return a result for \"${name}\"`)\n    }\n    await recordBenchmark([result], groupName(options), meta ? new Map([[name, meta]]) : undefined)\n    if (writeResult) {\n      await writeResultArtifact(writeResult, result)\n    }\n    return result\n  }\n\n  const runFrom = async (\n    name: string,\n    source: string | BenchFromSource,\n  ): Promise<BenchResult> => {\n    const data = await resolveFromSource(source)\n    const benchmark: TestBenchmark = {\n      name: test.fullTestName,\n      tasks: [{ ...taskFromBaseline(name, data), rank: 1 }],\n    }\n    test.benchmarks.push(benchmark)","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/runtime/benchmark.ts#L368-L404","documentation":"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.","triggerScenarios":"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.","commonSituations":"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`.","solutions":["If using a custom provider, ensure `run()` returns exactly one `BenchResult` per registration with matching `name`.","Verify the registration name and the provider's output name match exactly (case, whitespace).","If using the default provider, report a Vitest bug with a reproduction (it should always return a result)."],"exampleFix":"// custom provider — before\nasync run(group) {\n  return results.filter(r => r.name !== 'skip') // omits a name\n}\n// after\nasync run(group) {\n  return group.registrations.map(reg => computeResult(reg)) // one per registration, name matched\n}","handlingStrategy":"validation","validationCode":"const byName = new Map(results.map(r => [r.name, r]))\nfor (const reg of group.registrations) {\n  if (!byName.has(reg.name)) throw new Error(`Provider missing result for \"${reg.name}\"`)\n}","typeGuard":"const hasResultForEvery = (results: { name: string }[], names: readonly string[]): boolean =>\n  names.every(n => results.some(r => r.name === n))","tryCatchPattern":null,"preventionTips":["In custom providers, return exactly one result per registration with matching `name`.","Unit-test the provider against a known registration set.","Avoid filtering or renaming results inside the provider."],"tags":["benchmark","custom-provider","validation","api-contract"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}