{"record":{"id":"fc7f4f04bd268fab","repo":"Mintplex-Labs/anything-llm","slug":"no-browser-tab-matching-targeturl-open-tabs","errorCode":null,"errorMessage":"No browser tab matching \"${targetUrl}\". Open tabs:\n${openTabs}","messagePattern":"No browser tab matching \"(.+?)\"\\. Open tabs:\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-computer/services/interface-service/utils/cdp-eval.js","lineNumber":94,"sourceCode":"    socket.on(\"open\", () => { clearTimeout(t); resolve(socket); });\n    socket.on(\"error\", (err) => { clearTimeout(t); reject(err); });\n  });\n\n  try {\n    const { targetInfos } = await cdpSend(ws, \"Target.getTargets\");\n    const pages = targetInfos.filter(\n      (t) => t.type === \"page\" && !t.url.startsWith(\"chrome://\") && !t.url.startsWith(\"devtools://\")\n    );\n    if (pages.length === 0) throw new Error(\"No browser pages open.\");\n\n    let target = pages[pages.length - 1];\n    if (targetUrl) {\n      const match = pages.find(\n        (p) => p.url.includes(targetUrl) || p.title.toLowerCase().includes(targetUrl.toLowerCase())\n      );\n      if (!match) {\n        const openTabs = pages.map((p) => `- ${p.title} ${p.url}`).join(\"\\n\");\n        throw new Error(`No browser tab matching \"${targetUrl}\". Open tabs:\\n${openTabs}`);\n      }\n      if (match) target = match;\n    }\n\n    const { sessionId } = await cdpSend(ws, \"Target.attachToTarget\", {\n      targetId: target.targetId,\n      flatten: true,\n    });\n\n    await cdpSend(ws, \"Runtime.enable\", {}, sessionId);\n\n    const evalResult = await cdpSend(ws, \"Runtime.evaluate\", {\n      expression: code,\n      returnByValue: true,\n      awaitPromise: true,\n      userGesture: true,\n    }, sessionId);\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/open-computer/services/interface-service/utils/cdp-eval.js#L76-L112","documentation":"Thrown by cdp-eval when a targetUrl filter argument was supplied but no open page matches: matching is substring 'url.includes(targetUrl)' OR case-insensitive 'title.includes(targetUrl)'. The error lists every open tab (title + URL) to make the mismatch obvious. The default without a filter is the most recently opened page, so this only fires when an explicit tab selector was passed.","triggerScenarios":"Invoking the eval helper with a URL/title fragment (e.g. 'github.com/myrepo') when no open tab contains that substring in URL or title; the tab was closed or navigated away between calls; typo/case mismatch in the URL fragment (URL match is case-sensitive, only title match lowercases); auth redirect changed the URL so the fragment no longer appears.","commonSituations":"Agent assumes a page is still open after a redirect or popup closed it; targeting by document title that changes dynamically (SPA title updates); passing a full title with different casing/emoji than the tab shows.","solutions":["Read the 'Open tabs:' list in the error and re-issue with a substring that actually appears in one of the listed URLs (URLs are the stable choice)","If the tab was closed, re-open/navigate to the target URL first, then retry with the same filter","Prefer a distinctive URL fragment (hostname+path piece) over titles, which change with page state","Drop the filter entirely to act on the most recent tab when any tab is acceptable"],"exampleFix":"# before: filter no longer matches after a redirect\nnode cdp-eval.js 'console.log(1)' 'github.com/login'\n# after: use the post-login URL fragment shown in 'Open tabs:'\nnode cdp-eval.js 'console.log(1)' 'github.com/dashboard'","handlingStrategy":"validation","validationCode":"async function tabMatches(filter) {\n  const targets = await (await fetch('http://127.0.0.1:9222/json/list')).json();\n  const pages = targets.filter((t) => t.type === 'page' && !t.url.startsWith('chrome://') && !t.url.startsWith('devtools://'));\n  return pages.some((p) => p.url.includes(filter) || p.title.toLowerCase().includes(filter.toLowerCase()));\n}\nif (filter && !(await tabMatches(filter))) { /* re-open the page or drop the filter */ }","typeGuard":null,"tryCatchPattern":"try { await evalInPage(expr, filter); } catch (e) { if (/No browser tab matching/.test(e.message)) { /* e.message lists open tabs — pick a fresh substring from it and retry once */ } else throw e; }","preventionTips":["Prefer URL-fragment selectors over titles — titles change with SPA state, URLs survive longer","Re-derive the selector after any navigation/redirect step instead of caching it for the whole session","Parse the 'Open tabs:' list from the error to self-correct instead of failing the whole task"],"tags":["chrome","cdp","devtools","tab-targeting","open-computer"],"backgroundTag":"cdp-tab-not-found","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}