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

+7 -1
View File
@@ -1537,7 +1537,13 @@ CLI, unit tests (24) + integration tests (2).
`check_requirements()` deliberately **always returns ok**: `run_bridges()`
aborts *all* bridges when one's requirements fail and this dependency is
optional, so a missing Playwright/browser must be a per-call `503` (with an
install hint), never take down simplex/llm/nextcloud. Playwright's sync API is
install hint), never take down simplex/llm/nextcloud. Install is
`scripts/bootstrap.sh --browser`; when `playwright install` fails (notably on a
host with an IPv6 address but no global IPv6 route — Playwright's downloader
forces `autoSelectFamily` + a dual-stack resolver that prefers IPv6 and hangs
instead of falling back to IPv4), bootstrap falls back to
`scripts/playwright-browsers.py`, which fetches the same pinned artifacts over
IPv4 and lays them out where Playwright expects. Playwright's sync API is
bound to its creating thread and the bridge serves each request on a new one,
so the driver runs the **async** API on one dedicated event-loop thread and
serializes whole operations behind an `asyncio.Lock`, submitting coroutines