n8n-io/n8n · error · Error
Failed to create new tab
Error message
Failed to create new tab
What it means
Thrown by AgentBrowserAdapter.newPage when, after running `tab new` and refreshing tabs, there is no active tab AND the tabs array is empty (so the last-element fallback also fails). The literal message is a plain Error (not an McpBrowserError subclass). This indicates the `agent-browser` CLI accepted the tab-new command but produced no tab — a session-level inconsistency.
Source
Thrown at packages/@n8n/mcp-browser/src/adapters/agent-browser.ts:274
async listTabs(): Promise<PageInfo[]> {
return (await this.refreshTabs()).map((t) => ({ id: t.tabId, title: t.title, url: t.url }));
}
async listTabSessionIds(): Promise<string[]> {
return await Promise.resolve(this.tabCache.map((t) => t.tabId));
}
async listTabIds(): Promise<string[]> {
return (await this.listTabs()).map((t) => t.id);
}
async newPage(url?: string): Promise<PageInfo> {
if (url) AgentBrowserAdapter.assertSafeArg(url, 'URL');
await this.run(['tab', 'new', ...(url ? [url] : [])]);
const tabs = await this.refreshTabs();
const active = tabs.find((t) => t.active) ?? tabs[tabs.length - 1];
if (!active) throw new Error('Failed to create new tab');
return { id: active.tabId, title: active.title, url: active.url };
}
async closePage(pageId: string): Promise<void> {
await this.switchToTab(pageId);
await this.run(['tab', 'close']);
this.tabCache = this.tabCache.filter((t) => t.tabId !== pageId);
this.urlCache.delete(pageId);
}
async focusPage(pageId: string): Promise<void> {
await this.switchToTab(pageId);
}
// =========================================================================
// Navigation
// =========================================================================
View on GitHub (pinned to 5ac6606e81)
Solutions
- Call adapter.close() then adapter.launch(config) again to reset the session, then retry newPage.
- Check the gateway logs for a relay disconnect or extension disconnect around the same time.
- Verify only one gateway/agent-browser session is using the SESSION_NAME 'n8n-computer-use'.
- Run `agent-browser --session n8n-computer-use tab list` manually to inspect session state.
Example fix
// before
const page = await adapter.newPage(url);
// after — reset session on failure
async function robustNewPage(adapter, config, url) {
try {
return await adapter.newPage(url);
} catch (err) {
if (/Failed to create new tab/.test(err.message)) {
await adapter.close();
await adapter.launch(config);
return await adapter.newPage(url);
}
throw err;
}
} Defensive patterns
Strategy: fallback
Type guard
function isNewTabFailure(error: unknown): boolean {
return error instanceof Error && /Failed to create new tab/.test(error.message);
} Try / catch
try {
return await adapter.newPage(url);
} catch (err) {
if (isNewTabFailure(err)) {
await adapter.close();
await adapter.launch(config);
return await adapter.newPage(url);
}
throw err;
} Prevention
- Reset the agent-browser session (close + launch) before retrying newPage.
- Ensure only one process uses the SESSION_NAME at a time.
- Watch for relay/extension disconnects in the logs around new-tab failures.
When it happens
Trigger: Calling adapter.newPage(url?) — the run(['tab', 'new', ...]) call does not throw, but the subsequent refreshTabs() returns an empty array, so `tabs.find(t => t.active)` is undefined and `tabs[tabs.length - 1]` is also undefined.
Common situations: The agent-browser session is in a bad state (no browser window attached); the browser crashed between the tab-new command and the tab-list refresh; a CDP/relay disconnect happened mid-operation; the session name collided and the new tab landed in a different session.
Related errors
- Page not found: ${pageId}
- agent-browser failed
- Invalid ${role}: argument cannot start with '-' (got: ${JSON
- agent-browser action failed
- No executable path for ${browser}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/991074bcea1fc9af.
Report an issue: GitHub.