{"record":{"id":"64e7976b17ddbade","repo":"vitest-dev/vitest","slug":"browser-provider-is-not-defined-for-the-project","errorCode":null,"errorMessage":"Browser provider is not defined for the project \"${child.project.name}\". This is a bug in Vitest. Please, open a new issue with a reproduction.","messagePattern":"Browser provider is not defined for the project \"(.+?)\"\\. This is a bug in Vitest\\. Please, open a new issue with a reproduction\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/browser/src/node/plugins/pluginContext.ts","lineNumber":50,"sourceCode":"  }\n}\n\nasync function generateContextFile(\n  this: Rollup.PluginContext,\n  globalServer: ParentBrowserProject,\n) {\n  const commands = Object.keys(globalServer.commands)\n  // The provider instance is initialized lazily when a page opens, so reading\n  // `child.provider` here races and can be `undefined` before the first page is\n  // opened. The provider name is uniform across a project's instances and is\n  // already resolved on the config, so read it from there for this shared\n  // (cached) context module. The instance is still used below for the\n  // preview-only user-event import.\n  const child = [...globalServer.children][0]\n  const provider = child.provider\n  const providerName = child.config.browser.provider?.name\n  if (!providerName) {\n    throw new Error(\n      `Browser provider is not defined for the project \"${child.project.name}\". This is a bug in Vitest. Please, open a new issue with a reproduction.`,\n    )\n  }\n\n  const commandsCode = commands\n    .filter(command => !command.startsWith('__vitest'))\n    .map((command) => {\n      return `    [\"${command}\"]: (...args) => __vitest_browser_runner__.commands.triggerCommand(\"${command}\", args),`\n    })\n    .join('\\n')\n\n  const userEventNonProviderImport = await getUserEventImport(\n    provider,\n    this.resolve.bind(this),\n  )\n  const distContextPath = slash(`/@fs/${resolve(__dirname, 'context.js')}`)\n\n  return `","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/browser/src/node/plugins/pluginContext.ts#L32-L68","documentation":"pluginContext builds the cached browser-runner context module that is shared across a project's instances. It reads the provider name from the resolved config (child.config.browser.provider?.name) rather than the lazily-initialized provider instance. If that config field is absent, the framework considers it an internal invariant violation and asks the user to file a bug, because the config resolution layer should always populate provider.name before this code runs.","triggerScenarios":"Reaching pluginContext with a project whose config.browser.provider object exists but has no `name` field, or where config resolution was bypassed (e.g. a custom Vitest integration that constructs TestProject manually). The code path is hit when the orchestrator tester module is first requested by the browser.","commonSituations":"A regression in config resolution after upgrading Vitest; a third-party plugin that mutates config.browser.provider after resolution; running a canary/linked build of @vitest/browser where resolveConfig did not run; an edge case with a custom provider object literal missing the name property.","solutions":["Verify you are on a released, mutually-compatible version of vitest and @vitest/browser (no version skew after a partial upgrade).","Check that browser.provider is a known string ('playwright' | 'webdriverio' | 'preview') in your config, not a hand-rolled object.","Reinstall node_modules to rule out a partially-linked monorepo build.","If the issue reproduces on a clean install, file the bug report the error asks for, including vitest version, provider, and a minimal reproduction."],"exampleFix":"// before - hand-rolled provider object, no name resolved\nbrowser: { provider: { name: undefined } as any }\n// after - use a known provider string and let Vitest resolve it\nbrowser: { provider: 'playwright' }","handlingStrategy":"validation","validationCode":"function hasResolvedProvider(cfg: { browser?: { provider?: { name?: string } | string } }): boolean {\n  const p = cfg.browser?.provider\n  return typeof p === 'string' ? p.length > 0 : !!p && typeof p.name === 'string' && p.name.length > 0\n}","typeGuard":"function isKnownProviderName(name: unknown): name is 'playwright' | 'webdriverio' | 'preview' {\n  return name === 'playwright' || name === 'webdriverio' || name === 'preview'\n}","tryCatchPattern":null,"preventionTips":["Pin mutually-compatible versions of vitest and @vitest/browser.","Always specify browser.provider as a known string, never a hand-rolled object.","Reinstall node_modules after partial upgrades to clear stale links."],"tags":["browser-provider","config","internal-invariant","browser"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}