Files
MrTHROS 1119c84e2e Fix CDP capture hang when Chrome exposes component-extension targets (#56)
* Fix CDP capture hang when Chrome exposes component-extension targets

The CDP backends connect to `targets[0]` from Chrome's `/json` endpoint,
assuming the first target is the page tab. On environments where Chrome
ships built-in component extensions (e.g. Cast / Media Router,
`chrome-extension://nkeimhogjdpnpccoofpli`), those extensions appear as
`background_page` targets *before* the page in `/json`. Navigation and
`Page.captureScreenshot` commands sent to a background_page never return,
so `_cdp_send` blocks on its 180s `ws.recv()` timeout and every render
fails with an empty error — even for trivial pages like example.com.

This is environment-specific: clean headless Chrome on Linux CI has no
such extensions, so `targets[0]` happens to be the page there. On a
typical developer machine (and any Chrome with a force-installed or
component extension) it breaks.

Filter `/json` targets for `type == "page"` before connecting, falling
back to the raw list if none is reported. Applied to all three CDP
connection sites: backends/cdp.py, backends/fast_cdp.py, and
strategies/connection.py.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(cdp): extend page-target filter to all strategy files + fix bare --headless

The original PR correctly identified the root cause (background_page targets
from Chrome extensions appearing before real page targets in /json), but only
patched the 3 backend files. The same unfiltered targets[0] pattern existed in
5 more strategy files, and all 6 strategy files used the deprecated bare
--headless flag (which hangs on modern Chrome, as noted in the backend code).

Changes:
- Extract pick_page_ws_url() helper in connection.py to DRY the filter logic
- Apply page-target filtering to cdp_oneshot, cdp_pipelined_tabs,
  cdp_pipelined_dc, cdp_overlap, cdp_multitab
- Fix --headless → --headless=new in all 6 strategy files

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: yichuan520030910320 <yichuan_wang@berkeley.edu>
2026-06-21 17:26:59 -07:00
..
2026-06-01 22:41:36 -07:00
2026-06-01 22:41:36 -07:00