different-ai/openwork · error · Error
Could not resolve built-in browser CDP target.
Error message
Could not resolve built-in browser CDP target.
What it means
resolveBrowserCdpTargetId polls the app's CDP target list for a target whose URL contains the built-in browser tab's marker URL, up to a fixed timeout. If no matching target appears before the polling loop exhausts, it throws this error, meaning the automation layer cannot attach to the built-in browser view via Chrome DevTools Protocol.
Source
Thrown at apps/desktop/electron/browser-panel.mjs:147
const targets = await response.json();
return Array.isArray(targets) ? targets : [];
}
async function resolveBrowserCdpTargetId(tabId) {
const marker = encodeURIComponent(`openwork-browser-tab:${tabId}`);
const deadline = Date.now() + BROWSER_TARGET_RESOLVE_TIMEOUT_MS;
while (Date.now() < deadline) {
const targets = await listCdpTargets().catch(() => []);
const target = targets.find((candidate) => (
candidate?.type === "page" &&
typeof candidate.id === "string" &&
typeof candidate.url === "string" &&
candidate.url.includes(marker)
));
if (target?.id) return target.id;
await new Promise((resolve) => setTimeout(resolve, BROWSER_TARGET_RESOLVE_INTERVAL_MS));
}
throw new Error("Could not resolve built-in browser CDP target.");
}
async function openBrowserUrlForAutomation(rawUrl, provider = "auto") {
const requestedProvider = String(provider || "auto").trim().toLowerCase();
if (requestedProvider && requestedProvider !== "auto" && requestedProvider !== "builtin") {
throw new Error(`Browser provider is not available yet: ${requestedProvider}`);
}
const url = normalizeBrowserUrl(rawUrl);
const tab = createBrowserTab("about:blank", { select: true });
await tab.view.webContents.loadURL(browserTargetMarkerUrl(tab.tabId));
const targetId = await resolveBrowserCdpTargetId(tab.tabId);
await tab.view.webContents.loadURL(url);
return {
provider: "builtin",
browser_url: cdpBrowserUrl(),
target_id: targetId,
tab_id: tab.tabId,
url,View on GitHub (pinned to 2b7df46e8a)
Solutions
- Retry the automation call — the target may register shortly after the timeout
- Check that the built-in browser tab still exists and its webContents loaded the marker URL successfully
- Ensure CDP/debugging is available for the Electron session (no flags disabling remote debugging)
- Increase BROWSER_TARGET_RESOLVE_INTERVAL_MS / poll attempts if targets register slowly on the target hardware
Example fix
// before
const targetId = await resolveBrowserCdpTargetId(tab.tabId);
// after
let targetId;
try { targetId = await resolveBrowserCdpTargetId(tab.tabId); }
catch { await tab.view.webContents.loadURL(browserTargetMarkerUrl(tab.tabId)); targetId = await resolveBrowserCdpTargetId(tab.tabId); } Defensive patterns
Strategy: retry
Validate before calling
const tabs = listBrowserTabs();
if (!tabs.some(t => String(t.tabId) === String(tabId))) throw new Error(`tab ${tabId} is not open`); Type guard
function isResolvedTargetId(v) { return typeof v === 'string' && v.length > 0; } Try / catch
try {
const targetId = await resolveBrowserCdpTargetId(tabId);
} catch (e) {
if (e.message.includes('Could not resolve built-in browser CDP target')) {
// wait and retry once, or surface a 'browser not ready' state
} else throw e;
} Prevention
- Retry with backoff around automation calls
- Confirm the tab loaded its marker URL before resolving the CDP target
- Keep the tab alive for the duration of resolution (don't close mid-poll)
- Monitor app logs for CDP target registration delays on slow machines
When it happens
Trigger: Calling openBrowserUrlForAutomation (or resolveBrowserCdpTargetId directly) when the WebContentsView for the tab has not finished creating/registered a CDP target with the marker URL in browserTargetMarkerUrl(tabId), or the polling interval x attempts elapses before the target appears.
Common situations: Slow machine or heavy load delaying target registration; the built-in browser view failed to attach to CDP; Electron/CDP debugging not enabled for that session; navigating away from the marker page before the target resolves; a race where the tab was closed mid-resolution.
Related errors
- CDP target list failed: HTTP ${response.status}
- Agent context diagnostics timeout must be between 1 ms and 3
- Electron desktop helper is unavailable: ${command}
- Electron desktop helper is unavailable: ${prop}
- Failed to open browser
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/50922cd2329e91c1.
Report an issue: GitHub.