{"record":{"id":"991074bcea1fc9af","repo":"n8n-io/n8n","slug":"failed-to-create-new-tab","errorCode":null,"errorMessage":"Failed to create new tab","messagePattern":"Failed to create new tab","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/mcp-browser/src/adapters/agent-browser.ts","lineNumber":274,"sourceCode":"\n\tasync listTabs(): Promise<PageInfo[]> {\n\t\treturn (await this.refreshTabs()).map((t) => ({ id: t.tabId, title: t.title, url: t.url }));\n\t}\n\n\tasync listTabSessionIds(): Promise<string[]> {\n\t\treturn await Promise.resolve(this.tabCache.map((t) => t.tabId));\n\t}\n\n\tasync listTabIds(): Promise<string[]> {\n\t\treturn (await this.listTabs()).map((t) => t.id);\n\t}\n\n\tasync newPage(url?: string): Promise<PageInfo> {\n\t\tif (url) AgentBrowserAdapter.assertSafeArg(url, 'URL');\n\t\tawait this.run(['tab', 'new', ...(url ? [url] : [])]);\n\t\tconst tabs = await this.refreshTabs();\n\t\tconst active = tabs.find((t) => t.active) ?? tabs[tabs.length - 1];\n\t\tif (!active) throw new Error('Failed to create new tab');\n\t\treturn { id: active.tabId, title: active.title, url: active.url };\n\t}\n\n\tasync closePage(pageId: string): Promise<void> {\n\t\tawait this.switchToTab(pageId);\n\t\tawait this.run(['tab', 'close']);\n\t\tthis.tabCache = this.tabCache.filter((t) => t.tabId !== pageId);\n\t\tthis.urlCache.delete(pageId);\n\t}\n\n\tasync focusPage(pageId: string): Promise<void> {\n\t\tawait this.switchToTab(pageId);\n\t}\n\n\t// =========================================================================\n\t// Navigation\n\t// =========================================================================\n","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/mcp-browser/src/adapters/agent-browser.ts#L256-L292","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst page = await adapter.newPage(url);\n\n// after — reset session on failure\nasync function robustNewPage(adapter, config, url) {\n  try {\n    return await adapter.newPage(url);\n  } catch (err) {\n    if (/Failed to create new tab/.test(err.message)) {\n      await adapter.close();\n      await adapter.launch(config);\n      return await adapter.newPage(url);\n    }\n    throw err;\n  }\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":"function isNewTabFailure(error: unknown): boolean {\n  return error instanceof Error && /Failed to create new tab/.test(error.message);\n}","tryCatchPattern":"try {\n  return await adapter.newPage(url);\n} catch (err) {\n  if (isNewTabFailure(err)) {\n    await adapter.close();\n    await adapter.launch(config);\n    return await adapter.newPage(url);\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["mcp-browser","agent-browser","tabs","session"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}