Skip to content

fix(setup): Playwright Chromium failure becomes best-effort warn, not exit 1#1900

Open
DavidMiserak wants to merge 1 commit into
garrytan:mainfrom
DavidMiserak:fix/setup-playwright-warn-not-exit
Open

fix(setup): Playwright Chromium failure becomes best-effort warn, not exit 1#1900
DavidMiserak wants to merge 1 commit into
garrytan:mainfrom
DavidMiserak:fix/setup-playwright-warn-not-exit

Conversation

@DavidMiserak
Copy link
Copy Markdown

Carving out the Playwright-warn change from #1883 as a focused PR per
@jbetala7's review request. Coordinated with #1838 — see "Relationship
to #1838" below.

Problem

The Playwright Chromium install in ./setup is the riskiest step in the
whole script: it needs network, talks to a Microsoft CDN, on Windows it
bounces through Node.js because of a Bun pipe bug, and on locked-down
corporate machines it may not even be allowed to run. Until now, any
failure in that step was fatal (exit 1) and aborted ./setup mid-run,
before skills got registered, hooks got installed, or migrations ran.

A re-run would start over from the top, hit the same Chromium download
issue, fail the same way. There was no clean way to get a working gstack
install on a machine where Chromium was unreachable, even though every
non-browser feature would have worked fine.

Fix

Replace both exit 1 paths in the Playwright install/verify block with a
$_PW_FAIL_REASON accumulator. On failure, the script:

  • Prints a named warning to stderr identifying which sub-step failed:
    chromium-install, windows-no-node, windows-node-modules, or
    post-install-launch.
  • Lists the affected browser-driven features (/qa, /design-review,
    make-pdf, sidebar, /pair-agent).
  • On Windows, includes the Bun-on-Windows pipe-bug link and the
    node -e "require('playwright')" verify command.
  • Tells the user to re-run ./setup to retry — at which point only the
    Playwright step needs to succeed, because skills, hooks, and
    migrations are already in place from earlier steps.

All other setup behavior is unchanged. The script exits 0 in the
warn-only path and the user gets a usable gstack install minus browser
features.

Tests

test/setup-playwright-warn-not-exit.test.ts — 5 tests, exit-code-path
exercised (not source-grep):

  1. No exit 1 reachable from the block — source-anchored regex
    on the live block extracted from setup.
  2. _PW_FAIL_REASON accumulator + named warning present — same
    source-anchored extraction.
  3. Functional: install failure → exit 0 + warning. Runs the live
    block in bash with stubbed ensure_playwright_browser (always fails)
    and stubbed bunx (fails). Asserts script exits 0, stderr contains
    warning: Playwright Chromium is unavailable (chromium-install),
    and the retry hint fires.
  4. Side-by-side: old bug shape exits 1. Inlines the OLD exit 1
    path with the same stubs and confirms it returned non-zero. Proves
    the exit-code difference is real, not a quoting illusion.
  5. Functional: post-install launch failure also degrades to warn.
    bunx succeeds, ensure_playwright_browser keeps failing — asserts
    exit 0 with reason post-install-launch.
$ bun test test/setup-playwright-warn-not-exit.test.ts
 5 pass / 0 fail / 14 expect() calls

$ bun test test/setup-*.test.ts
 70 pass / 0 fail / 165 expect() calls

Test plan

  • bun test test/setup-playwright-warn-not-exit.test.ts — 5 pass
  • bun test test/setup-*.test.ts — 70 pass
  • bash -n setup — syntax OK
  • Manually traced the new path for each _PW_FAIL_REASON value

Relationship to #1838

This PR and #1838 modify the same Playwright block in setup but
solve non-overlapping problems:

PR What it changes
#1838 Which Chromium version gets installed (pins bunx playwright install to the bundled playwright/package.json version so the install-time and runtime versions don't drift) + tightens ensure_playwright_browser() to assert executablePath() exists.
this PR What happens when install fails (exit 1_PW_FAIL_REASON accumulator + named warning, no abort).

Both can land — they're complementary. Whichever lands first, the other
needs a small rebase. I'm happy to rebase this PR onto #1838 if the
maintainers prefer that order (likely the cleaner sequence, since #1838
is closer to merging).

Relationship to #1883

This PR is the "(2) Playwright warn-don't-exit" split @jbetala7 asked
for on #1883. The third split — the phase reorder — will be a separate
PR against fresh main with an issue describing the failure modes it
fixes. #1883 stays open until all three splits are visible, then I'll
close it with links to all three.

Sibling: #1898 (the two bug fixes, opened first).

… exit 1

Replaces both `exit 1` paths in the Playwright install/verify block with a
$_PW_FAIL_REASON accumulator that prints a named warning to stderr and
returns control. Previously a Chromium download failure (network blip,
locked-down corporate machine, missing Node.js on Windows) would abort
./setup mid-run with no skills registered, no hooks installed, no
migrations applied — and a re-run would start over from the top.

Now the failure only disables browser-driven features (/qa,
/design-review, make-pdf, sidebar, /pair-agent); skills, hooks, and
migrations land normally. The warning names which sub-step failed
(chromium-install / windows-no-node / windows-node-modules /
post-install-launch) so users and bug reports can be specific, and
tells the user to re-run ./setup to retry just this step.

Tests (5) exercise the actual block from setup with stubbed
ensure_playwright_browser and bunx, simulate install + post-install
failures, and assert the script exits 0 with the named warning. One
side-by-side test inlines the OLD bug shape and confirms it returned
non-zero, so the exit-code difference is proven, not just asserted.

Coordinates with garrytan#1838 (pins Playwright install version): both touch the
same code block, so whichever lands first needs the other to rebase. The
changes are complementary — garrytan#1838 fixes which Chromium build gets
installed; this PR fixes what happens when the install fails.

Carved out from garrytan#1883 per @jbetala7's review request.
@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Jun 7, 2026

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant