{"record":{"id":"3e818937f405364a","repo":"stablyai/orca","slug":"browser-error-3e8189","errorCode":"browser_error","errorMessage":"Could not attach debugger. DevTools may already be open for this tab.","messagePattern":"Could not attach debugger\\. DevTools may already be open for this tab\\.","errorType":"exception","errorClass":"BrowserError","httpStatus":null,"severity":"error","filePath":"src/main/browser/browser-screencast-stream.ts","lineNumber":232,"sourceCode":"      clearTimeout(timeout)\n    }\n  }\n}\n\nexport async function startBrowserScreencast(\n  webContents: WebContents,\n  options: BrowserScreencastOptions\n): Promise<BrowserScreencastSession> {\n  if (webContents.isDestroyed()) {\n    throw new BrowserError('browser_tab_not_found', 'Browser tab is no longer available')\n  }\n\n  const dbg = webContents.debugger\n  let debuggerLease: ElectronDebuggerLease | null = null\n  try {\n    debuggerLease = acquireElectronDebugger(webContents)\n  } catch {\n    throw new BrowserError(\n      'browser_error',\n      'Could not attach debugger. DevTools may already be open for this tab.'\n    )\n  }\n\n  let closed = false\n  let stopping = false\n  let seq = 0\n  let lastFrameSentAt = 0\n  let deviceMetricsOverridden = false\n  let snapshotGeneration = 0\n  let navigationCaptureTimer: ReturnType<typeof setTimeout> | null = null\n  let pendingFrame: PendingScreencastFrame | null = null\n  let pendingFrameTimer: ReturnType<typeof setTimeout> | null = null\n  let resolveDone!: () => void\n  const done = new Promise<void>((resolve) => {\n    resolveDone = resolve\n  })","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/browser/browser-screencast-stream.ts#L214-L250","documentation":"Electron permits only one CDP debugger session per WebContents. acquireElectronDebugger() calls debugger.attach('1.3'); if DevTools is already open for that tab or another CDP consumer (screencast, WS proxy, agent-browser) already holds the debugger, the attach rejects and startBrowserScreencast converts it to this browser_error. The lease system (electron-debugger-lease.ts) allows multiple consumers to share one attach via a Symbol-owner Set, but an external attach (DevTools) bypasses that mechanism.","triggerScenarios":"Calling startBrowserScreencast while DevTools is open on that tab; a prior screencast session crashed without releasing its debugger lease; the CDP WS proxy is connected to the same WebContents.","commonSituations":"Developer left DevTools open during testing; a crashed screencast whose lease was never released; two Orca features competing for the same tab's debugger.","solutions":["Close DevTools for that browser tab, then retry.","Stop any other screencast or CDP-WS-proxy session on the same WebContents.","Retry after ensuring only one consumer holds the debugger lease."],"exampleFix":"// before\nconst session = await startBrowserScreencast(wc, opts)\n\n// after\ntry {\n  const session = await startBrowserScreencast(wc, opts)\n} catch (e) {\n  if (e instanceof BrowserError && e.code === 'browser_error' && /DevTools/.test(e.message)) {\n    // prompt user to close DevTools, then retry\n  }\n  throw e\n}","handlingStrategy":"try-catch","validationCode":"const dbg = webContents.debugger\nif (dbg.isAttached()) {\n  // debugger already held by another consumer; either reuse via lease or ask user to close DevTools\n}\nconst session = await startBrowserScreencast(webContents, options)","typeGuard":null,"tryCatchPattern":"try {\n  const session = await startBrowserScreencast(wc, opts)\n} catch (e) {\n  if (e instanceof BrowserError && e.code === 'browser_error' && /DevTools/.test(e.message)) {\n    // prompt user to close DevTools for this tab, then retry\n  }\n  throw e\n}","preventionTips":["Close DevTools before starting a screencast — Electron allows only one debugger per WebContents.","Ensure prior screencast sessions are stopped (call session.stop()) before starting a new one.","Use the debugger-lease system (acquireElectronDebugger) to share a single attach across consumers."],"tags":["electron","debugger","cdp","screencast","devtools"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}