{"record":{"id":"1bca568775ec260c","repo":"musistudio/claude-code-router","slug":"browser-navigate-could-not-resolve-an-active-tab","errorCode":null,"errorMessage":"browser_navigate could not resolve an active tab.","messagePattern":"browser_navigate could not resolve an active tab\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/electron/src/main/browser-automation-mcp.ts","lineNumber":815,"sourceCode":"      case \"browser_tab_close\": {\n        await this.ensureBrowserOpen();\n        const session = this.resolveOptionalSession(args);\n        this.assertCanMutate(session);\n        const tabId = readString(args.tabId) || session?.ref.tabId;\n        if (!tabId) {\n          throw new Error(\"browser_tab_close requires tabId or session.\");\n        }\n        const state = builtInBrowserService.closeAutomationTab(tabId);\n        this.removeSessionsForTab(tabId);\n        return browserWindowState(state);\n      }\n      case \"browser_navigate\": {\n        await this.ensureBrowserOpen();\n        const session = this.resolveOptionalSession(args);\n        this.assertCanMutate(session);\n        const tabId = readString(args.tabId) || session?.ref.tabId || builtInBrowserService.getAutomationState().activeTabId;\n        if (!tabId) {\n          throw new Error(\"browser_navigate could not resolve an active tab.\");\n        }\n        const url = requiredString(args.url, \"browser_navigate requires url.\");\n        const waitUntil = normalizeWaitUntil(readString(args.waitUntil), \"interactive\");\n        const readiness = await waitForReadiness(\n          builtInBrowserService.getAutomationWebContents(tabId),\n          waitUntil,\n          clampInteger(readNumber(args.timeoutMs) ?? defaultWaitTimeoutMs, 100, 120000),\n          () => builtInBrowserService.navigateAutomationTab(url, tabId),\n          url\n        );\n        const state = builtInBrowserService.getAutomationState();\n        const webContents = builtInBrowserService.getAutomationWebContents(tabId);\n        const handoff = await maybeRequestHandoffAfterNavigation(webContents, readiness, {\n          requestedUrl: url,\n          session: session?.ref,\n          tabId,\n          waitUntil\n        });","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/electron/src/main/browser-automation-mcp.ts#L797-L833","documentation":"Thrown by the browser_navigate MCP tool when tabId, session ref, and the browser's activeTabId are all unresolvable. Unlike tab_activate/tab_close, navigate does fall back to the currently active tab — this error means the automation browser has no active tab at all (e.g. all tabs were closed or the window state is empty).","triggerScenarios":"Calling browser_navigate with no tabId and no session when builtInBrowserService.getAutomationState().activeTabId is null — typically right after the last tab was closed while the hidden browser stayed open.","commonSituations":"A multi-step automation script closes the working tab, then navigates; the hidden automation browser was opened with no initial tab.","solutions":["Call browser_navigate with an explicit url but no tabId — it will create a tab when one is absent — or call browser_open first to establish state.","Pass tabId from a prior browser_tab_list/browser_navigate result.","Attach a session (which pins a tabId) before closing tabs in a script."],"exampleFix":"// before\nawait call(\"browser_tab_close\", { tabId });\nawait call(\"browser_navigate\", { url }); // no active tab left\n\n// after\nawait call(\"browser_tab_close\", { tabId });\nawait call(\"browser_navigate\", { url, tabId: newTabId }); // or create tab via browser_navigate url flow","handlingStrategy":"fallback","validationCode":"const state = await call(\"browser_tab_list\", {});\nif (!state.tabs.length) { await call(\"browser_open\", { url: \"about:blank\" }); } // ensure a tab exists\nawait call(\"browser_navigate\", { url });","typeGuard":null,"tryCatchPattern":"try { await call(\"browser_navigate\", { url }); } catch (e) { if (e instanceof Error && e.message.includes(\"could not resolve an active tab\")) { await call(\"browser_open\", { url }); } else throw e; }","preventionTips":["Open a tab before navigating","Pass explicit tabId in multi-tab scripts","Recover by opening rather than retrying blindly"],"tags":["mcp","browser-automation","no-active-tab","navigation"],"backgroundTag":"no-active-browser-tab","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}