{"record":{"id":"82f71d571eba4653","repo":"puppeteer/puppeteer","slug":"page-is-not-found","errorCode":null,"errorMessage":"Page is not found","messagePattern":"Page is not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/puppeteer-core/src/bidi/BrowserContext.ts","lineNumber":219,"sourceCode":"   */\n  getTargetForPage(page: BidiPage): BidiPageTarget | undefined {\n    return this.#targets.get(page)?.[0];\n  }\n\n  override async newPage(options?: CreatePageOptions): Promise<Page> {\n    using _guard = await this.waitForScreenshotOperations();\n\n    const type =\n      options?.type === 'window'\n        ? Bidi.BrowsingContext.CreateType.Window\n        : Bidi.BrowsingContext.CreateType.Tab;\n\n    const context = await this.userContext.createBrowsingContext(type, {\n      background: options?.background,\n    });\n    const page = this.#pages.get(context)!;\n    if (!page) {\n      throw new Error('Page is not found');\n    }\n    if (this.#defaultViewport) {\n      try {\n        await page.setViewport(this.#defaultViewport);\n      } catch (error) {\n        // Tolerate not supporting `browsingContext.setViewport`. Only log it.\n        this.#logger?.(DEBUG_PREFIXES.error)?.(error);\n      }\n    }\n    if (options?.type === 'window' && options?.windowBounds !== undefined) {\n      try {\n        await this.browser().setWindowBounds(\n          context.windowId,\n          options.windowBounds,\n        );\n      } catch (error) {\n        // Tolerate not supporting `browser.setClientWindowState`. Only log it.\n        this.#logger?.(DEBUG_PREFIXES.error)?.(error);","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/puppeteer/puppeteer/blob/d484e21c17f6023826fefdcdeeb553e04a7aaed8/packages/puppeteer-core/src/bidi/BrowserContext.ts#L201-L237","documentation":"Thrown inside BrowserContext.newPage() right after the WebDriver BiDi server acknowledges a new browsing context, when that context has not yet been registered in the internal #pages map (the non-null assertion at line 217 is immediately re-checked at 218). It represents an internal state desync between the BiDi event stream and puppeteer's page registry, not a user mistake.","triggerScenarios":"Calling browserContext.newPage() / browser.newPage() on a BiDi-backed browser where the browsingContext.contextCreated event either did not arrive or was not processed before the synchronous map lookup at line 217-219; or concurrent newPage() calls against the same incognito user context.","commonSituations":"A browser build that omits or delays the contextCreated event (older/non-conforming WebDriver BiDi implementations); racing context creation before puppeteer has attached its event listeners; concurrent newPage() from multiple coroutines against one BrowserContext.","solutions":["Retry the newPage() call once after the page map has had time to populate; if it reproduces deterministically, file a puppeteer bug — the invariant should hold.","Upgrade puppeteer and the browser (Chrome 122+ / a WebDriver BiDi-compliant build) so the contextCreated event is reliably emitted.","Serialize concurrent newPage() calls on the same user context to avoid the registration race."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return await ctx.newPage(); } catch (e) { if (e instanceof Error && e.message === 'Page is not found') { /* retry once after the event stream catches up */ await new Promise(r => setTimeout(r, 50)); return await ctx.newPage(); } throw e; }","preventionTips":["Serialize concurrent newPage() calls on one BrowserContext.","Keep puppeteer and the browser on current releases so contextCreated is reliably emitted."],"tags":["bidi","race-condition","internal-invariant"],"backgroundTag":null,"analyzedSha":"d484e21c17f6023826fefdcdeeb553e04a7aaed8","analyzedAt":"2026-08-12T06:33:19.665Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}