{"id":"199f83fe6a4695ab","repo":"vitest-dev/vitest","slug":"benchmark-provider-loaded-from-provider-did-n","errorCode":null,"errorMessage":"Benchmark provider loaded from \"${provider}\" did not have a default export.","messagePattern":"Benchmark provider loaded from \"(.+?)\" did not have a default export\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/benchmark.ts","lineNumber":114,"sourceCode":"\nlet cachedProvider: Promise<BenchmarkProvider> | undefined\n\nasync function loadProviderModule(\n  provider: string,\n  moduleRunner: TestModuleRunner,\n): Promise<BenchmarkProvider> {\n  let mod: Record<string, any>\n  try {\n    mod = await moduleRunner.import(provider)\n  }\n  catch (error) {\n    throw new Error(\n      `Failed to load benchmark provider from \"${provider}\".`,\n      { cause: error },\n    )\n  }\n  if (mod.default == null) {\n    throw new Error(\n      `Benchmark provider loaded from \"${provider}\" did not have a default export.`,\n    )\n  }\n  return mod.default\n}\n\n/**\n * Resolves the benchmark provider for the current worker, importing a custom\n * provider module on first use. The result is cached for the lifetime of the\n * worker so a custom provider is imported at most once.\n */\nexport function resolveBenchmarkProvider(\n  config: SerializedConfig,\n  moduleRunner: TestModuleRunner,\n): Promise<BenchmarkProvider> {\n  if (!cachedProvider) {\n    const provider = config.benchmark.provider\n    cachedProvider = !provider","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/runtime/benchmark.ts#L96-L132","documentation":"Thrown by `loadProviderModule` (benchmark.ts:114) when the custom benchmark provider module imports successfully but has no `default` export (`mod.default == null`). Vitest expects the provider object (implementing `BenchmarkProvider.run`) to be the default export; a named-only export or a side-effect module is rejected.","triggerScenarios":"Authoring a benchmark provider with `export const provider = { run(...) {} }` and no default export; a provider whose default export is conditionally undefined; pointing at a file that isn't the provider entry.","commonSituations":"Forgetting `export default` when writing a provider; refactoring that moved the implementation to a named export; loading the wrong module.","solutions":["Add `export default { async run(group) { /* return BenchResult[] */ } }` to the provider module.","Confirm the configured path points to the file with the default export.","Ensure the default export implements `BenchmarkProvider` (`run(group): Promise<BenchResult[]>`)."],"exampleFix":"// before\nexport const myProvider = { async run(group) { /* ... */ } }\n// after\nexport default { async run(group) { /* return BenchResult[] */ } }","handlingStrategy":"validation","validationCode":"const mod = await import(providerPath)\nif (mod.default == null) throw new Error(`${providerPath} must have a default export`)","typeGuard":"const hasDefaultProvider = (m: Record<string, unknown>): m is { default: { run(g: any): Promise<any[]> } } =>\n  typeof m.default === 'object' && typeof (m.default as any)?.run === 'function'","tryCatchPattern":null,"preventionTips":["Always `export default` the provider object.","Validate that the default export has a `run` function.","Keep provider authoring consistent with the `BenchmarkProvider` interface."],"tags":["benchmark","custom-provider","default-export","config"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}