Commit baeff45
fix(build): playwright extension parses the Playwright 1.58+
Fixes #3089
## Problem
The `playwright` build extension reads `npx playwright install
--dry-run` to find each browser's install directory and download URL.
Playwright 1.58 changed the per-browser header, so the extension's
`grep` finds nothing and the image build fails at that step with exit
code 1:
```
< 1.58 browser: chromium-headless-shell version 143.0.7499.4
>= 1.58 Chrome Headless Shell 151.0.7922.34 (playwright chromium-headless-shell v1234)
```
There is a second problem hiding behind the first. The old blocks were
five lines (install location, download url, two fallback urls, blank),
so `grep -A5` was exact. The Chrome-for-Testing blocks in 1.58+
(`chromium` and `chromium-headless-shell`, the default install) are
three lines (install location, download url, blank; Firefox and WebKit
still print the fallbacks), so `-A5` runs into the next browser's
`Install location:` line. The downstream `grep "Install location:" | cut
| xargs` then joins two paths and `basename` returns the *next*
browser's directory: with the header grep alone fixed,
`chromium-headless-shell` gets unpacked into `firefox-<build>/`. Any
grep-only fix (including the pnpm patch shared in #3089) has this bug.
## Fix
- The header match accepts both formats: `grep -E "browser: <name>
|\(playwright <name> v"`. The trailing space / `v` keep `chromium` from
matching the `chromium-headless-shell` block in either format.
- The context window is narrowed to `-A2`, the two lines the extension
actually reads. Both formats put `Install location:` and `Download url:`
immediately after the header.
- A unit test asserts the generated header pattern selects each
browser's block in both formats and never another browser's.
I left the `sed "s/mac-arm64/linux/g"` rewrite alone, and I do not think
the "dead `linux64` URLs" report in #3089 is reachable from the
extension. The `--dry-run` executes inside the Linux build container, so
the URL it prints is already the Linux one and there is nothing for the
rewrite to match. Checked by running the same command in a container:
```
$ docker run --rm --platform linux/amd64 node:22-bookworm-slim \
sh -c 'npx -y playwright@1.62.0 install --dry-run'
Chrome Headless Shell 151.0.7922.34 (playwright chromium-headless-shell v1234)
Download url: https://cdn.playwright.dev/builds/cft/151.0.7922.34/linux64/chrome-headless-shell-linux64.zip
Firefox 153.0 (playwright firefox v1538)
Download url: https://cdn.playwright.dev/dbazure/download/playwright/builds/firefox/1538/firefox-debian-12.zip
```
Rewriting `mac-arm64` to `linux64` would also be wrong for < 1.58, where
the Linux artifact is `…-linux.zip`, so changing it would trade a dead
branch for an incorrect one.
## Verification
Ran the generated extraction (`grep -A2 -m1 -E … | grep "Install
location:" | cut | xargs | basename`, and the same for `Download url:`)
against real `--dry-run` output from Playwright 1.57.0 and 1.62.0, for
all four browser keys:
| output | browser | directory | url |
|---|---|---|---|
| 1.57 | chromium | chromium-1200 | chromium-linux.zip |
| 1.57 | chromium-headless-shell | chromium_headless_shell-1200 |
chromium-headless-shell-linux.zip |
| 1.57 | firefox | firefox-1497 | firefox-linux.zip |
| 1.57 | webkit | webkit-2227 | webkit-ubuntu-20.04.zip |
| 1.62 | chromium | chromium-1234 | chrome-linux.zip |
| 1.62 | chromium-headless-shell | chromium_headless_shell-1234 |
chrome-headless-shell-linux.zip |
| 1.62 | firefox | firefox-1538 | firefox-linux.zip |
| 1.62 | webkit | webkit-2336 | webkit-mac-26-arm64.zip |
(The webkit 1.62 URL shows the mac name only because my sample output
came from a Mac; in the build container the dry-run prints Linux URLs.)
End to end: built a `node:22-bookworm-slim` image (linux/amd64) that
runs the extension's generated `RUN` steps verbatim for
`chromium-headless-shell` against Playwright 1.62.0, then launched the
browser through Playwright with
`PLAYWRIGHT_BROWSERS_PATH=/ms-playwright`:
```
install dir: chromium_headless_shell-1234
Downloading from https://cdn.playwright.dev/builds/cft/151.0.7922.34/linux64/chrome-headless-shell-linux64.zip
/ms-playwright/chromium_headless_shell-1234/chrome-headless-shell-linux64
title: pw-e2e-ok | version: 151.0.7922.34
```
So the Chrome-for-Testing archive layout unpacks into the directory
Playwright's registry expects, and the browser starts.
## Changeset
`@trigger.dev/build` patch.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>install --dry-run output (#4881)1 parent f151b7a commit baeff45
3 files changed
Lines changed: 60 additions & 1 deletion
File tree
- .changeset
- packages/build/src/extensions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
199 | 212 | | |
200 | 213 | | |
201 | 214 | | |
| |||
317 | 330 | | |
318 | 331 | | |
319 | 332 | | |
320 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
321 | 336 | | |
322 | 337 | | |
323 | 338 | | |
| |||
0 commit comments