{"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/526360e320da9d1b36074be5ed64fe76e5bbfbbd/open-computer/services/interface-service/utils/cdp-eval.js#L76-L112","documentation":"Thrown by cdp-eval.js when targetUrl was supplied but no open page matches by URL-substring or title-substring (case-insensitive). The message lists every open tab (title + url) so the caller can correct the target. This is a targeting failure, not a connection failure.","triggerScenarios":"Passing a targetUrl that does not substring-match any open tab's URL or title; the desired tab was navigated to a different URL since the call; casing or trailing-slash differences defeat the includes() check.","commonSituations":"User supplied a hostname (example.com) but the tab navigated to www.example.com/auth; trailing slash mismatch; the SPA changed document.title to something unrelated; multiple tabs share a similar URL and the wrong heuristic picked first.","solutions":["Read the 'Open tabs' list in the error to find the actual URL/title of the intended tab.","Pass a more specific (or exact) targetUrl substring that uniquely matches the desired tab.","Ensure the intended tab is focused/loaded before invoking cdp-eval.","If the URL changed dynamically, re-query open tabs and retry with the current URL."],"exampleFix":"# before\nnode cdp-eval.js \"document.title\" \"localhost\"\n\n# after — match the actual URL from the open-tabs list\nnode cdp-eval.js \"document.title\" \"localhost:3000/dashboard\"","handlingStrategy":"validation","validationCode":"// Confirm a tab matching targetUrl exists before evaluating.\nasync function tabMatches(targetUrl) {\n  const tabs = JSON.parse(await httpGet('http://127.0.0.1:9222/json'));\n  const q = targetUrl.toLowerCase();\n  return tabs.some(t => t.type === 'page' && (t.url.toLowerCase().includes(q) || (t.title||'').toLowerCase().includes(q)));\n}","typeGuard":null,"tryCatchPattern":"try {\n  await evalInTab(targetUrl, code);\n} catch (e) {\n  if (/No browser tab matching/.test(e.message)) {\n    // e.message lists all open tabs — re-derive the correct targetUrl from it\n  }\n  throw e;\n}","preventionTips":["Pass a unique, exact URL substring rather than a generic hostname.","Re-query open tabs if the SPA navigated since the call was prepared.","Read the 'Open tabs' list in the error to pick the right target."],"tags":["cdp","chromium","browser-debugging","tabs","targeting"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}