stablyai/orca · error · BrowserError

browser_cdp_error

browser_cdp_error

Error message

Could not attach debugger. DevTools may already be open for this tab.

What it means

Same root cause as error 801 but in CdpBridge's ensureDebuggerAttached(). Electron permits only one debugger per WebContents. If BrowserManager hasn't pre-attached the debugger and the attach('1.3') call fails (DevTools open, or another consumer attached externally), this error is thrown with code browser_cdp_error. The bridge then sets up Page.enable, DOM.enable, Network.enable, Target.setAutoAttach, and anti-detection scripts, so a failed attach means none of that initialization happened.

Source

Thrown at src/main/browser/cdp-bridge.ts:1142

        // guest may already be destroyed
      }
    }
  }

  private async ensureDebuggerAttached(guest: Electron.WebContents): Promise<void> {
    const tabId = this.resolveTabId(guest.id)
    const state = this.getOrCreateTabState(tabId)
    if (state.debuggerAttached && guest.debugger.isAttached()) {
      return
    }

    try {
      // Why: BrowserManager already attached the debugger; reuse it to avoid "another debugger is already attached."
      if (!guest.debugger.isAttached()) {
        guest.debugger.attach('1.3')
      }
    } catch {
      throw new BrowserError(
        'browser_cdp_error',
        'Could not attach debugger. DevTools may already be open for this tab.'
      )
    }

    const sender = this.makeCdpSender(guest)
    await sender('Page.enable')
    await sender('DOM.enable')
    await sender('Network.enable')

    // Why: OOPIF iframes are invisible to the parent CDP session; flatten:true gives each a targetable sessionId.
    await sender('Target.setAutoAttach', {
      autoAttach: true,
      waitForDebuggerOnStart: false,
      flatten: true
    })

    // Why: CDP attach exposes automation signals (navigator.webdriver) that Cloudflare checks; override per new document.

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Close DevTools for that browser tab, then retry.
  2. Stop other CDP consumers (screencast, WS proxy) on the same WebContents.
  3. Retry the automation command — ensureDebuggerAttached is idempotent and will attempt re-attach.
Defensive patterns

Strategy: try-catch

Validate before calling

if (guest.debugger.isAttached()) {
  // already attached by another consumer; command should proceed
} else if (webContents.isDestroyed()) {
  throw new Error('Cannot attach debugger: WebContents destroyed')
}
await bridge.click(ref)

Try / catch

try {
  await bridge.click(ref)
} catch (e) {
  if (e instanceof BrowserError && e.code === 'browser_cdp_error' && /DevTools/.test(e.message)) {
    // prompt user to close DevTools, then retry
  }
  throw e
}

Prevention

When it happens

Trigger: DevTools is open for the target tab; a prior CDP session didn't detach cleanly; the debugger was detached (e.g., by a detach event) and re-attach fails on the next command.

Common situations: Developer has DevTools open while running automation; concurrent screencast and automation sessions on the same tab; Electron version quirk causing attach flakiness.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/d188166eeb58b392. Report an issue: GitHub.