Mintplex-Labs/anything-llm · error · Error

No browser tab matching "${targetUrl}". Open tabs: ${openTab

Error message

No browser tab matching "${targetUrl}". Open tabs:
${openTabs}

What it means

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.

Source

Thrown at open-computer/services/interface-service/utils/cdp-eval.js:94

    socket.on("open", () => { clearTimeout(t); resolve(socket); });
    socket.on("error", (err) => { clearTimeout(t); reject(err); });
  });

  try {
    const { targetInfos } = await cdpSend(ws, "Target.getTargets");
    const pages = targetInfos.filter(
      (t) => t.type === "page" && !t.url.startsWith("chrome://") && !t.url.startsWith("devtools://")
    );
    if (pages.length === 0) throw new Error("No browser pages open.");

    let target = pages[pages.length - 1];
    if (targetUrl) {
      const match = pages.find(
        (p) => p.url.includes(targetUrl) || p.title.toLowerCase().includes(targetUrl.toLowerCase())
      );
      if (!match) {
        const openTabs = pages.map((p) => `- ${p.title} ${p.url}`).join("\n");
        throw new Error(`No browser tab matching "${targetUrl}". Open tabs:\n${openTabs}`);
      }
      if (match) target = match;
    }

    const { sessionId } = await cdpSend(ws, "Target.attachToTarget", {
      targetId: target.targetId,
      flatten: true,
    });

    await cdpSend(ws, "Runtime.enable", {}, sessionId);

    const evalResult = await cdpSend(ws, "Runtime.evaluate", {
      expression: code,
      returnByValue: true,
      awaitPromise: true,
      userGesture: true,
    }, sessionId);

View on GitHub (pinned to 526360e320)

Solutions

  1. Read the 'Open tabs' list in the error to find the actual URL/title of the intended tab.
  2. Pass a more specific (or exact) targetUrl substring that uniquely matches the desired tab.
  3. Ensure the intended tab is focused/loaded before invoking cdp-eval.
  4. If the URL changed dynamically, re-query open tabs and retry with the current URL.

Example fix

# before
node cdp-eval.js "document.title" "localhost"

# after — match the actual URL from the open-tabs list
node cdp-eval.js "document.title" "localhost:3000/dashboard"
Defensive patterns

Strategy: validation

Validate before calling

// Confirm a tab matching targetUrl exists before evaluating.
async function tabMatches(targetUrl) {
  const tabs = JSON.parse(await httpGet('http://127.0.0.1:9222/json'));
  const q = targetUrl.toLowerCase();
  return tabs.some(t => t.type === 'page' && (t.url.toLowerCase().includes(q) || (t.title||'').toLowerCase().includes(q)));
}

Try / catch

try {
  await evalInTab(targetUrl, code);
} catch (e) {
  if (/No browser tab matching/.test(e.message)) {
    // e.message lists all open tabs — re-derive the correct targetUrl from it
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/fc7f4f04bd268fab. Report an issue: GitHub.