{"record":{"id":"71d148749eecc0af","repo":"stablyai/orca","slug":"browser-tab-changed","errorCode":"browser_tab_changed","errorMessage":"Browser page ${target.browserPageId} changed while evaluating; retry the command","messagePattern":"Browser page (.+?) changed while evaluating; retry the command","errorType":"error_code","errorClass":"BrowserError","httpStatus":null,"severity":"warning","filePath":"src/main/browser/agent-browser-bridge.ts","lineNumber":1583,"sourceCode":"          releaseDebugger = acquireElectronDebugger(wc).release\n          const { result, exceptionDetails } = (await wc.debugger.sendCommand('Runtime.evaluate', {\n            expression,\n            returnByValue: true,\n            awaitPromise: true\n          })) as {\n            result: { value?: unknown; description?: string }\n            exceptionDetails?: { text: string; exception?: { description?: string } }\n          }\n          if (exceptionDetails) {\n            throw new BrowserError(\n              'browser_eval_error',\n              exceptionDetails.exception?.description ?? exceptionDetails.text\n            )\n          }\n\n          const currentTarget = this.resolveCommandTarget(worktreeId, target.browserPageId)\n          if (currentTarget.webContentsId !== target.webContentsId) {\n            throw new BrowserError(\n              'browser_tab_changed',\n              `Browser page ${target.browserPageId} changed while evaluating; retry the command`\n            )\n          }\n          return {\n            result:\n              result.value !== undefined\n                ? typeof result.value === 'object' && result.value !== null\n                  ? JSON.stringify(result.value)\n                  : String(result.value)\n                : (result.description ?? ''),\n            origin: wc.getURL()\n          }\n        } catch (error) {\n          if (error instanceof BrowserError) {\n            throw error\n          }\n          if (!this.getWebContents(target.webContentsId)) {","sourceCodeStart":1565,"sourceCodeEnd":1601,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/browser/agent-browser-bridge.ts#L1565-L1601","documentation":"Thrown by evaluate() after a successful Runtime.evaluate when re-resolving the command target shows the browserPageId now maps to a different webContentsId than when the command started — the tab navigated to a new page or was replaced during eval. The message explicitly instructs retry. This guards against returning a result computed in a now-stale page context.","triggerScenarios":"evaluate() captures target.webContentsId, sends Runtime.evaluate (which awaits the promise), and during that await the page navigates (SPAroute change, redirect, or full navigation) causing resolveCommandTarget to return a different webContentsId for the same browserPageId. SPA navigations that swap the WebContents, or client-side redirects, trigger this.","commonSituations":"Evaluating an expression on a page that auto-redirects (login flows, meta-refresh); SPA route transitions mid-eval; the agent issued a click that triggered navigation while an eval was in flight; tab replacement (e.g. prerender activation).","solutions":["Retry the evaluate command — the message explicitly says 'retry the command' and the new target will be current.","If the page is prone to navigation, wait for a stable URL/load event before issuing the eval.","For SPA flows, use a wait(url/load) before evaluate to ensure the page has settled."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"function isTabChangedError(e: unknown): boolean {\n  return e instanceof BrowserError && e.code === 'browser_tab_changed'\n}","tryCatchPattern":"for (let attempt = 0; attempt < 2; attempt++) {\n  try {\n    return await bridge.evaluate(expression, worktreeId, browserPageId)\n  } catch (e) {\n    if (e instanceof BrowserError && e.code === 'browser_tab_changed' && attempt === 0) continue\n    throw e\n  }\n}","preventionTips":["Call wait({ load: 'load' }) or wait({ url }) before evaluate on navigation-prone pages","Avoid issuing click/navigate and evaluate back-to-back on the same tab without a settle","Track navigation state and only evaluate when the page is stable"],"tags":["browser","navigation","tab-changed","retry"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}