Skip to content

Browser launches: wait for a cold start within the caller's budget - #93

Merged
agorischek merged 2 commits into
mainfrom
flaky-devtools
Nov 20, 2026
Merged

agorischek merged 2 commits into
mainfrom
flaky-devtools

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

The flake

The CLI's headless browser launches failed with "The browser did not answer Browser.getVersion in time" (Linux, pipe transport) or "The browser did not open its DevTools endpoint" (Windows, port transport). Reruns passed.

Failure (Nov 17–20) Jobs failed Branches On main Same SHA passed elsewhere
viewer.spec.ts:128 "screenshot --page …": DevTools timeout (browser (rest), windows-integration) 14 12 1 3
action.test.mjs:799 "the snapshot script renders both sides…": "The browser did not open its DevTools endpoint" (windows-node) 1 (on main at 2026-11-20 17:49Z) 1 1 —

Cause

Browser::connect gave the browser a fixed 30 s to start and answer. Launching the runner's own Chrome 40 times in a row on otherwise idle runners (a temporary diagnostic workflow, run 44809551795) gave these times:

Runner First (cold) launch Later launches: median / p95
ubuntu-24.04 6.4 s 0.19 / 0.20 s
macos-latest 6.5 s (two at once) 0.5–2.3 / 1.5–3.9 s
windows-2025, one at a time 9.0 s 0.25 / 0.34 s
windows-2025, four at once 13.6–14.9 s 0.7–1.5 / 2.0–2.3 s

None hung. In CI, the failing launch is the first system-Chrome launch in a job that is also running Playwright's browsers, the viewer's extraction and the build's I/O. On a loaded runner that cold start can go past 30 s.

Fix

The launch now gets the caller's own budget: LaunchOptions.startup is the capture's or the checks' --timeout, a minute or more, as the rest of their work already has. The wait is still on the real endpoint (DevToolsActivePort, then Browser.getVersion). A browser that exits still fails at once, as does a cancelled launch. A timeout now says how long it waited and includes the browser's stderr tail, which the Browser.getVersion timeout path left out. This is not a retry. The cold start is an external cost, and the fixed 30 s fell below the budget every caller already gives its work.

A new unit test checks the behaviour: a stand-in browser that never answers fails after a 1 s startup budget, and the error names the budget and quotes the browser's output. Before this change the test would wait 30 s and fail.

The CLI gave a headless browser a fixed 30 s to start and answer its DevTools
connection. A cold start (the first launch on a machine, its files not yet
cached or scanned) takes several times a warm one: launching the runner's
Chrome 40 times in a row took 6.4 s the first time on Linux, 6.5 s on macOS and
9 to 15 s on Windows, then 0.2 to 2 s. In CI the first launch comes from a job
already busy with Playwright's browsers and the viewer's extraction, and
crossed 30 s: "did not answer Browser.getVersion in time" and "did not open its
DevTools endpoint" in viewer.spec's page screenshot (browser rest,
windows-integration) and the Action's snapshot test (windows-node).

The start now has the caller's own budget (a capture's or the checks'
--timeout, a minute or more), as the rest of its work does. A browser that
exits still fails at once, and a timeout says how long it waited and what the
browser printed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The port-transport handshake can exceed the startup deadline, and the elapsed-time test can fail spuriously by counting launch-gate contention against the startup budget.

2 open issues
What changed in this PR

This PR addresses flaky cold browser launches by replacing the fixed 30-second startup wait with the caller’s timeout budget in CLI captures and renderer checks.

Changes:

  • Add a startup budget to browser launch options and pass it from both callers.
  • Include the configured wait and browser stderr in timeout diagnostics.
  • Add a regression test for an unresponsive browser with a short startup budget.
File Description
packages/​cli/​src/​snapshot.rs Pass the capture timeout into browser startup.
packages/​cli/​src/​check/​stage.rs Pass the renderer-check timeout into browser startup.
packages/​cli/​src/​browser/​tests.rs Update launch options and test startup timeout diagnostics.
packages/​cli/​src/​browser/​session.rs Apply configurable startup deadlines and improve timeout errors.
packages/​cli/​src/​browser/​mod.rs Define and document the startup budget option.

Review effort: Balanced

Comment thread packages/cli/src/browser/session.rs Resolved
Comment thread packages/cli/src/browser/tests.rs Resolved
…dget too

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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