puppeteer/puppeteer · error · Error
Page is not found
Error message
Page is not found
What it means
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.
Source
Thrown at packages/puppeteer-core/src/bidi/BrowserContext.ts:219
*/
getTargetForPage(page: BidiPage): BidiPageTarget | undefined {
return this.#targets.get(page)?.[0];
}
override async newPage(options?: CreatePageOptions): Promise<Page> {
using _guard = await this.waitForScreenshotOperations();
const type =
options?.type === 'window'
? Bidi.BrowsingContext.CreateType.Window
: Bidi.BrowsingContext.CreateType.Tab;
const context = await this.userContext.createBrowsingContext(type, {
background: options?.background,
});
const page = this.#pages.get(context)!;
if (!page) {
throw new Error('Page is not found');
}
if (this.#defaultViewport) {
try {
await page.setViewport(this.#defaultViewport);
} catch (error) {
// Tolerate not supporting `browsingContext.setViewport`. Only log it.
this.#logger?.(DEBUG_PREFIXES.error)?.(error);
}
}
if (options?.type === 'window' && options?.windowBounds !== undefined) {
try {
await this.browser().setWindowBounds(
context.windowId,
options.windowBounds,
);
} catch (error) {
// Tolerate not supporting `browser.setClientWindowState`. Only log it.
this.#logger?.(DEBUG_PREFIXES.error)?.(error);View on GitHub (pinned to d484e21c17)
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.
Defensive patterns
Strategy: retry
Try / catch
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; } Prevention
- Serialize concurrent newPage() calls on one BrowserContext.
- Keep puppeteer and the browser on current releases so contextCreated is reliably emitted.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Execution context was destroyed, most likely because of a na
- Missing target for DevTools page (id = ${devtoolsTargetId})
- Launch aborted
- Error: failed to find element matching selector "${selector}
- Unknown CDP session with id ${id}
AI-assisted analysis of puppeteer/puppeteer@d484e21c17 (2026-08-12).
Data as JSON: /api/errors/82f71d571eba4653.
Report an issue: GitHub.