Skip to content

auto-connect fails with Chrome M144+ chrome://inspect remote debugging #516

@jonathanglasmeyer

Description

@jonathanglasmeyer

Hey y'all, thanks for your work on agent-browser. I'm trying to use --auto-connect to attach to my regular Chrome profile (with all my existing sessions/cookies), and I'm running into an issue with Chrome M144+'s new remote debugging mechanism. Below is Claude Opus 4.6's assessment after a good bit of digging - hopefully it's somewhat useful? :)

Environment

  • agent-browser: v0.13.0
  • Chrome: 145.0.7632.76 (arm64)
  • OS: macOS 15.3 (Darwin 24.6.0, Apple Silicon)
  • Remote debugging enabled via: chrome://inspect/#remote-debugging UI toggle (not CLI flag)

Problem

--auto-connect fails despite PR #432 being merged:

$ agent-browser --auto-connect screenshot
✗ No running Chrome instance with remote debugging found.

DevToolsActivePort exists and contains valid data:

$ cat ~/Library/Application\ Support/Google/Chrome/DevToolsActivePort
9222
/devtools/browser/1ed17c43-53f8-4ecf-beb8-f3f33e7d5af2

Port 9222 is open (TCP connects), but Chrome M144+'s chrome://inspect server has no HTTP endpoints:

$ curl -v http://127.0.0.1:9222/json/version
< HTTP/1.1 404 Not Found

Explicit --cdp with the full WebSocket URL also fails (likely due to Chrome's user-approval dialog timeout):

$ agent-browser --cdp "ws://127.0.0.1:9222/devtools/browser/1ed17c43-..." screenshot
✗ Failed to connect via CDP to ws://...

Root Cause

Chrome M144+ chrome://inspect/#remote-debugging uses a WebSocket-only server with no HTTP discovery API. Confirmed by Chrome team in ChromeDevTools/chrome-devtools-mcp#772.

The current auto-connect flow in autoConnectViaCDP fails because:

  1. probeDebugPort() calls /json/version → 404 → returns null
  2. Fallback passes HTTP URL to connectOverCDP → Playwright internally calls /json/version/ → 404 → fails
  3. Even with explicit ws:// URL via --cdp, the connection likely times out waiting for Chrome's user-approval dialog

How chrome-devtools-mcp (Google) solves this

Google's chrome-devtools-mcp works because it:

  1. Reads DevToolsActivePort directly
  2. Constructs ws://127.0.0.1:${port}${wsPath} without any HTTP probe
  3. Connects via Puppeteer's WebSocket transport directly
  4. Handles the user-approval dialog delay gracefully

Suggested Fix

  1. When DevToolsActivePort exists, construct the ws:// URL directly from file contents and skip probeDebugPort() entirely
  2. Pass the ws:// URL to connectOverCDP (Playwright should handle ws:// URLs without HTTP resolution)
  3. Increase the connection timeout to allow for Chrome's user-approval dialog (user must click "Allow" in Chrome before the connection succeeds)
  4. Consider adding a log message like "Waiting for approval in Chrome..." so the user knows to click Allow

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions