-
Notifications
You must be signed in to change notification settings - Fork 234
Description
Problem
In extension mode, CDP connections can hang indefinitely when the relay attempts to attach to non-page targets (service workers, shared workers, browser targets). This causes page.goto() and other operations to timeout even though the page loads correctly in the browser.
Root Cause
When Playwright calls Target.getTargets or Target.setAutoAttach, it discovers all CDP targets including:
service_workertargetsshared_workertargetsbrowsertargetsbackground_pagetargets
Attempting to route CDP commands to these non-page targets causes hangs because they don't respond to Page domain commands the way page targets do.
Proposed Solution
Filter CDP target discovery to only return actual page targets:
// In relay's CDP command routing
if (command === 'Target.getTargets') {
const result = await forwardToExtension(command, params);
// Filter to only page targets
result.targetInfos = result.targetInfos.filter(
t => t.type === 'page' && !t.url.startsWith('chrome')
);
return result;
}Working Implementation
I have a fix in my fork:
- https://github.com/parkerhancock/dev-browser
- Commit
007f90f- Fix CDP hangs by filtering non-page targets
The fix filters Target.getTargets responses and Target.attachedToTarget events to only include page-type targets with valid URLs.
Happy to submit a PR if there's interest.