-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[Feature]: Support Chrome M144+ Remote Debugging via chrome://inspect/#remote-debugging #40027
Description
🚀 Feature Request
Playwright's connectOverCDP() cannot connect to Chrome browsers (M144+) that have remote debugging enabled via chrome://inspect/#remote-debugging. This new Chrome feature allows users to enable remote debugging on an already-running browser instance without needing to restart Chrome with --remote-debugging-port.
Background
Starting from Chrome M144, users can enable remote debugging on a running Chrome instance:
- Navigate to
chrome://inspect/#remote-debugging - Follow the dialog UI to allow incoming debugging connections
- Chrome exposes a CDP endpoint (e.g.,
ws://127.0.0.1:9222/devtools/browser/<id>)
This is different from the traditional --remote-debugging-port approach:
- No need to restart Chrome
- Can enable debugging on-demand
- Uses a different internal protocol
Current Behavior
When attempting to connect to this type of endpoint:
const browser = await chromium.connectOverCDP('ws://127.0.0.1:9222/devtools/browser/<id>');
Playwright establishes the WebSocket connection successfully, but then times out waiting for expected protocol messages. The connection fails with:
Error: Timeout 30000ms exceeded.
Call log:
- <ws connecting> ws://127.0.0.1:9222/devtools/browser/<id>
- <ws connected> ws://127.0.0.1:9222/devtools/browser/<id>
Expected Behavior
Playwright should be able to connect to Chrome M144+ remote debugging endpoints, similar to how Puppeteer supports this via the handleDevToolsAsPage option.
Reference Implementation
Puppeteer (used by chrome-devtools-mcp) supports this through:
// Puppeteer's approach
await puppeteer.connect({
browserWSEndpoint: 'ws://127.0.0.1:9222/devtools/browser/<id>',
targetFilter: (target) => {
// Filter targets appropriately
return true;
},
defaultViewport: null,
handleDevToolsAsPage: true, // Key option for M144+ remote debugging
});
The handleDevToolsAsPage: true option enables Puppeteer to correctly handle the DevTools protocol variant used by Chrome M144+'s new remote debugging feature.
Use Cases
- Debugging user's browser - Connect to a user's existing Chrome session for support/debugging without requiring them to restart with special flags
- On-demand inspection - Enable remote debugging temporarily without disrupting the user's workflow
- CI/CD environments - Some CI setups may prefer enabling debugging on existing browser instances
- MCP servers / AI agents - AI coding assistants need to connect to user's existing browser for automation
Proposed Solution
Add a new option to connectOverCDP():
await chromium.connectOverCDP(endpointURL, {
handleDevToolsAsPage: boolean, // Support Chrome M144+ remote debugging
timeout: number,
headers: Record<string, string>,
});
Alternatively, detect the endpoint type automatically and handle both protocols transparently.
Environment
- Playwright version: v1.51.0
- Chrome version: M144+
- OS: All platforms