Skip to content

fix(cli): retry a slow Chrome start with backoff in render_page (#207) - #231

Merged
Madraka merged 1 commit into
mainfrom
claude/fix-207-chrome-start
Nov 14, 2026
Merged

Madraka merged 1 commit into
mainfrom
claude/fix-207-chrome-start

Conversation

@Madraka

@Madraka Madraka commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

What

render_page's Chrome start no longer fails a busy CI runner after two 20 s attempts. The render tests no longer spend part of their 50 s render budget on a cold Chrome start. A real renderer regression still fails: every render assertion is unchanged, and there is no skip.

Changes

packages/cli/src/render-chrome.ts

  • chromeRenderer(executable, options) takes three new options:
    • launches (default 3): how many times to try;
    • backoffMs (default 1 s): the pause before the second launch, doubled before each later one;
    • startMs (default 20 s): how long one launch may take to print its DevTools endpoint.
  • Each launch gets a new profile.
  • The error names the last failure and the number of launches, for example "Chrome did not start within 20 s (3 launches)".
  • A launch that hangs or exits is killed, and its profile is removed. A failed launch clears the shared Chrome only when it is still the current one, so two waiting sessions can't kill each other's relaunch.
  • A Chrome that crashes after it started is dropped. The next session launches a new one.
  • A new stop() ends the renderer's Chrome.
  • The launch and kill code moved into module-level launchChrome and killChrome, which keeps chromeRenderer short.

packages/cli/test/render-chrome.test.ts

  • The Chrome tests share one renderer. It starts in beforeAll with a 45 s start budget and a 200 s hook timeout, and afterAll stops it. The sessions use separate browser contexts (cdp.ts), so sharing a Chrome is safe; cloudhal studio does the same in production.
  • A Chrome that cannot start still fails every test, with the launch error.
  • Three fake-Chrome unit tests (shell scripts, Unix only):
    • a Chrome that keeps exiting gets 3 launches, each with a new profile;
    • a hung launch is killed after startMs, every launched process is gone afterwards, and the error says how long it waited;
    • when a later launch prints an endpoint, the renderer gets past starting.

Changeset: @cloudhal/cli patch.

Tests (run locally, one at a time)

  • pnpm exec vitest run test/render-chrome.test.ts in packages/cli: 7/7 passed in 24 s, with real Chrome.
  • The fake-Chrome tests passed three more runs in a row.
  • pnpm run typecheck (cli): clean.
  • Biome on the changed files: clean.
  • pnpm size:check: ok.

The first local run found a tight timing in the new hung-launch test. With a 300 ms budget, the fake's shell sometimes hadn't logged its pid yet. The budget is now 1 s, about 10× a normal shell start. The kill itself was verified outside vitest, and both fake processes were gone.

Closes #207

🤖 Generated with Claude Code

The render-chrome test failed on busy CI runners with "Chrome did not
start": two 20 s launches were not enough while turbo ran other suites.

- chromeRenderer: up to three launches (`launches`), each with a fresh
  profile, a doubling pause (`backoffMs`, 1 s), and a configurable start
  budget (`startMs`, 20 s). The error names the last failure and the count.
  A launch that exits on its own is dropped and its profile removed; a
  failed launch only clears the shared Chrome when it is still the current
  one. `stop()` ends the renderer's Chrome.
- The Chrome tests share one renderer, started in beforeAll with a 45 s
  start budget, so a cold start no longer eats a render's 50 s timeout.
  A Chrome that cannot start still fails every test with the launch
  error; renderer assertions are unchanged.
- Fake-Chrome unit tests: three launches with new profiles, a hung launch
  killed after startMs, and recovery when a later launch starts.

Closes #207

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Madraka <[email protected]>
@Madraka
Madraka merged commit f331cd6 into main Nov 14, 2026
8 checks passed
@Madraka
Madraka deleted the claude/fix-207-chrome-start branch November 14, 2026 11: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.

CI: render-chrome test fails when Chrome does not start on a busy runner

1 participant