Skip to content

v1.57.4.0 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

v1.57.4.0 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).

@trunk-io

trunk-io Bot commented Jun 7, 2026

Copy link
Copy Markdown

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

@jbetala7

jbetala7 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Verified — this is the Playwright carve-out from #1883 and it's correct. On main, a Chromium install/launch failure (or the Windows no-Node path) hits exit 1 and aborts ./setup before skills, hooks, and migrations register, so a re-run just re-fails at the same step and never finishes provisioning. Routing those failures through _PW_FAIL_REASON + a named warning while letting setup complete is the right call, and the Windows Node/@ngrok/ngrok require-checks are preserved — just redirected to the warn path instead of exit 1. Coordinates cleanly with the bundled-version pin in #1838. Looks correct.

@DavidMiserak DavidMiserak force-pushed the fix/setup-playwright-warn-not-exit branch from 396ab7e to 0a6c5bf Compare June 8, 2026 08:46
DavidMiserak added a commit to DavidMiserak/gstack that referenced this pull request Jun 8, 2026
…ability

setup used to interleave trivial filesystem ops, expensive compute,
settings.json mutations, and network/sudo steps in whatever order the
script grew. A Playwright Chromium download failing at step 2 would
abort before skills got registered at step 4, hooks landed at step 10,
or migrations ran at step 8.

This commit groups work by where failures actually come from:

  Phase A — filesystem (always succeeds): ~/.gstack/, welcome, GBrain detection
  Phase B — local compute (low fail): bun build, skill linking, migrations, regen
  Phase C — settings.json mutation (medium fail, reversible): team-mode + plan-tune hooks
  Phase D — external network/sudo/package managers (highest fail): coreutils, font, Playwright

Each phase is bracketed with a header comment; steps within are
renumbered (A1, A2, B1, B2a...).

The biggest behavior shift is the GBrain detect/regen split that the
new order requires: detection moves to A3 (filesystem scan only, no
dependencies), regen moves to B6 (runs after the binary is built and
skill docs are generated). Detection persists to
~/.gstack/gbrain-detection.json so B6 can read it.

A safety guard for that split: when gstack-gbrain-detect exits non-zero,
A3 removes both the temp file AND any pre-existing detection file from a
prior successful run. Without the guard, a stale "ok" detection file
would survive a failed detect and silently apply ~250 tokens of overhead
per planning skill to a user whose gbrain may no longer be installed.

Behavior preservation:
- bun_cmd routing in link_{codex,factory,opencode}_skill_dirs is
  unchanged (still buggy here). The fix is in garrytan#1898.
- gen:skill-docs:user still pipes through `tail -3` in B6 (still buggy
  here). The fix is in garrytan#1898.
- Playwright Chromium install/verify in D3 still exits 1 on failure
  (unchanged). The warn-don't-exit conversion is in garrytan#1900 and
  coordinates with garrytan#1838.

Splitting those keeps this PR reviewable as "a move plus the gbrain
split that the move requires," per @jbetala7's request on garrytan#1883.
@DavidMiserak DavidMiserak force-pushed the fix/setup-playwright-warn-not-exit branch from 0a6c5bf to 0668240 Compare June 8, 2026 09:29
@github-actions github-actions Bot changed the title fix(setup): Playwright Chromium failure becomes best-effort warn, not exit 1 v1.57.4.0 fix(setup): Playwright Chromium failure becomes best-effort warn, not exit 1 Jun 8, 2026
… 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.
@DavidMiserak DavidMiserak force-pushed the fix/setup-playwright-warn-not-exit branch from 0668240 to 12c0b89 Compare June 8, 2026 09:36
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.

2 participants