{"record":{"id":"7e3aa7aa474873a1","repo":"vitest-dev/vitest","slug":"can-t-find-browser-origin-url-for-project-this","errorCode":null,"errorMessage":"Can't find browser origin URL for project \"${this.name}\"","messagePattern":"Can't find browser origin URL for project \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/project.ts","lineNumber":484,"sourceCode":"\n  /** @internal */\n  public _getViteEnvironments(): DevEnvironment[] {\n    return Object.values(this.vite.environments || {})\n  }\n\n  /** @internal */\n  public async _openBrowserPage(sessionId: string, pool: {\n    reject: (error: Error) => void\n    parallel?: boolean\n  }): Promise<void> {\n    if (!this.browser) {\n      throw new Error(`browser is not initialized`)\n    }\n\n    const resolvedUrls = this.browser.vite.resolvedUrls\n    const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0]\n    if (!origin) {\n      throw new Error(\n        `Can't find browser origin URL for project \"${this.name}\"`,\n      )\n    }\n\n    const url = new URL('/__vitest_test__/', origin)\n    url.searchParams.set('sessionId', sessionId)\n    const otelCarrier = this.vitest._traces.getContextCarrier()\n    this.vitest._browserSessions.sessionIds.add(sessionId)\n    const sessionPromise = this.vitest._browserSessions.createSession(\n      sessionId,\n      this,\n      pool,\n      { otelCarrier },\n    )\n    const pagePromise = this.browser.provider.openPage(\n      sessionId,\n      url.toString(),\n      { parallel: pool.parallel ?? false },","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/project.ts#L466-L502","documentation":"After confirming the browser is initialized, _openBrowserPage reads this.browser.vite.resolvedUrls to find the local or network origin. If neither local[0] nor network[0] exists, there is no URL to build the test page address from, so it throws naming the project.","triggerScenarios":"The browser Vite server has no resolvedUrls (local/network both empty) when _openBrowserPage tries to construct the /__vitest_test__/ page URL.","commonSituations":"The dev server failed to bind/resolve URLs, a custom server config that suppresses resolvedUrls, the server starting in a mode that does not compute URLs, or a race reading resolvedUrls before server.listen finished.","solutions":["Check the Vite dev server startup logs for bind/listen errors.","Ensure server.host/port config is valid and the port is not already in use.","Avoid custom plugins that override resolvedUrls or server.listen behavior.","Retry after the server is fully ready; if persistent, file an issue with the server config."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure the dev server produced URLs before opening pages.\nfunction assertOrigin(urls: { local?: string[]; network?: string[] } | null | undefined) {\n  const origin = urls?.local?.[0] ?? urls?.network?.[0]\n  if (!origin) throw new Error('Browser dev server has no resolved URL; check server config / port.')\n  return origin\n}","typeGuard":"const hasResolvedUrl = (urls: { local?: string[]; network?: string[] } | null | undefined): boolean =>\n  Boolean(urls && (urls.local?.length || urls.network?.length))","tryCatchPattern":null,"preventionTips":["Verify the Vite dev server binds successfully (check ports).","Avoid plugins that override resolvedUrls or server.listen.","Wait for server ready before triggering browser page open."],"tags":["browser","vite-server","urls","initialization"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}