microsoft/playwright · error · Error
No open pages available.
Error message
No open pages available.
What it means
currentTabOrDie() throws 'No open pages available' when the tools backend's _currentTab is unset. It is the fail-fast accessor used by MCP tool backends (video, wait, snapshot) that require an active tab. There is no current tab if the context has no open pages or the active one was closed/crashed and not yet recreated.
Solutions
- Call the tool that opens/ensures a tab first (newTab / ensureTab), then snapshot/action tools.
- Check for open pages via a list tool before calling action tools; surface 'open a page' to the user/LLM.
- Have the backend auto-call ensureTab() so currentTab is never null when an action runs.
Defensive patterns
Strategy: validation
Validate before calling
// Call ensureTab/newTab before action tools.
async function ensureTabOrThrow(ctx) {
if (!ctx.currentTab()) await ctx.newTab();
return ctx.currentTabOrDie();
} Type guard
null
Try / catch
try { return await context.currentTabOrDie(); }
catch (e) {
if (/No open pages/.test(e.message)) { await context.newTab(); return context.currentTabOrDie(); }
throw e;
} Prevention
- Open a page before issuing action tools.
- Auto-ensure a tab exists at the start of each tool session.
When it happens
Trigger: Calling any MCP tool that goes through currentTabOrDie() (snapshot, video, wait, etc.) before a page exists, after the only page was closed, or after a crash before ensureTab() runs. Happens at the start of a session or right after closeTab removed the last page.
Common situations: First tool call in a fresh MCP session with no page yet. Calling an action tool after the user/script closed the only tab. Post-crash state where ensureTab hasn't recreated the page.
Related errors
- Tab not found
- This tab is already connected to another client
- Browser context was closed before the daemon could start
- Cannot disconnect from this worker
- Cannot find object to
AI-assisted analysis of microsoft/playwright@f1d33b5029 (2026-08-12).
Data as JSON: /api/errors/5ca96852c8b32215.
Report an issue: GitHub.
Appendix: source
Thrown at packages/playwright-core/src/tools/backend/context.ts:179
this._unhandledRejectionListeners.add(listener);
return () => this._unhandledRejectionListeners.delete(listener);
}
debugger() {
return this._rawBrowserContext.debugger;
}
tabs(): Tab[] {
return this._tabs;
}
currentTab(): Tab | undefined {
return this._currentTab;
}
currentTabOrDie(): Tab {
if (!this._currentTab)
throw new Error('No open pages available.');
return this._currentTab;
}
async newTab(): Promise<Tab> {
const browserContext = await this.ensureBrowserContext();
const page = await browserContext.newPage();
this._setCurrentTab(this._tabs.find(t => t.page === page)!);
return this._currentTab!;
}
async selectTab(index: number) {
const tab = this._tabs[index];
if (!tab)
throw new Error(`Tab ${index} not found`);
await tab.page.bringToFront();
await tab.updateWebMCPTools();
this._setCurrentTab(tab);
return tab;View on GitHub (pinned to f1d33b5029)