Repository navigation
Browser launches: wait for a cold start within the caller's budget - #93
Merged
Merged
Conversation
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>
There was a problem hiding this comment.
🟡 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
…dget too Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.
viewer.spec.ts:128"screenshot --page …": DevTools timeout (browser (rest), windows-integration)action.test.mjs:799"the snapshot script renders both sides…": "The browser did not open its DevTools endpoint" (windows-node)Cause
Browser::connectgave 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: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.startupis 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, thenBrowser.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 theBrowser.getVersiontimeout 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.