bridges: prime the Playwright browser over IPv4 when the downloader hangs

`playwright install chromium` failed on this host even though the CDN is
reachable. Root cause is Node, not the network: Playwright's bundled downloader
forces `autoSelectFamily` with a custom dual-stack resolver that resolves
`[6, 4]` and interleaves IPv6 first, and this box has an IPv6 address (a ULA)
with no global IPv6 route, so the first IPv6 connection blackholes and Node never
falls back to IPv4 -- the download stalls to the socket timeout. Raising
`PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT` only moved the hang from 30s to 600s;
`curl -4` fetches the same artifact at ~6 MB/s.

Playwright skips a browser whose directory holds an `INSTALLATION_COMPLETE`
marker, so prime the cache over IPv4 and the normal install becomes a no-op.

- `scripts/playwright-browsers.py`: reads the chromium/headless-shell/ffmpeg
  revisions and Chrome-for-Testing versions from Playwright's own
  `browsers.json`, downloads those exact artifacts with `curl -4`, extracts them
  into `PLAYWRIGHT_BROWSERS_PATH/<name>-<revision>/`, and writes the marker.
  Idempotent; prefers `unzip`, falls back to `zipfile` + chmod.
- `bootstrap.sh --browser`: if `playwright install` fails for chromium, fall
  back to the helper (firefox/webkit just warn).

Verified live: after priming, `playwright install chromium` exits 0 and the
browser bridge drives a real Chromium (goto/content/text/links/fill/select/
screenshot) over HTTP.
This commit is contained in:
gabby committed 2026-10-11 09:45:31 +00:00
1 parent 6240392632
commit e4961ef492
4 files changed
+199 -3

No files matched your search

+4
View File
@@ -854,6 +854,10 @@ screenshot, and click/fill/press/select to complete a flow. It is the first
bridge with a heavy optional dependency, so it is **disabled by default** and
installed with `scripts/bootstrap.sh --browser` (Playwright + Chromium land under
`.runtime/browser`; the bridge sets `PLAYWRIGHT_BROWSERS_PATH` there at launch).
If `playwright install` fails — notably on a host with an IPv6 address but no
global IPv6 route, where Playwright's downloader prefers IPv6 and hangs —
bootstrap falls back to `scripts/playwright-browsers.py`, which downloads the
same pinned artifacts over IPv4.
Unlike the others it owns a browser and keeps a **persistent profile**
(`.runtime/browser/profile`) so a login you do once survives across calls and
restarts — the browser analog of the SimpleX bridge owning its own daemon