Skip to content

fix(browser): fix the downloads live test flake at its three causes - #959

Merged
omartelo merged 2 commits into
mainfrom
fix/browser-downloads-flake
Oct 28, 2026
Merged

omartelo merged 2 commits into
mainfrom
fix/browser-downloads-flake

Conversation

@omartelo

@omartelo omartelo commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the flaky TestChromeDownloadsLandInDownloadsAndThePageStays, which failed on main (run 40584150744, macOS) and on #955. Three failures, three causes.

Linux: page load error net::ERR_ABORTED in attachment

Chrome reloads the page 1.46 to 1.70 seconds after an <a download> begins (24 samples, Chromium 155), and that reload aborts a navigation started before it. The answer was held 1.5 seconds after the download began, inside that spread, so the next browser_navigate sometimes lost the race. Product fix: downloadQuiet is now 2.5 seconds. The same race hit an agent's real next step, not only the test.

macOS and Windows: GUID-named files left in Downloads

Traced on the Windows runner: the extra files (4 KB to 33 MB) never had a Browser.downloadWillBegin or downloadProgress event. Browser.setDownloadBehavior applies to the whole browser, so Chrome's own background downloads (the optimization guide's models, which go through the profile's download manager with no page) were saved into the Downloads folder under their GUID and never renamed. In production that is the user's real ~/Downloads. Product fix: Chrome starts with OptimizationGuideModelDownloading and OptimizationTargetPrediction disabled, on top of chromedp's own disable-features list. docs/ceilings.md names the remaining trap: a background download a later Chrome adds would land the same way.

Windows: blank.csv ... State:inProgress

Test change, because the test asserted something the contract never promised. For a target=_blank download the click answers before the new tab hands over its URL, so the test polls page reads. A read names a download still running and the next read says when it ends (docs/browser-tab.md), but the loop stopped at the first read that named one. It now keeps polling until that download is no longer in progress. The assertions are unchanged: exactly one download, at the expected path, completed, with the expected contents.

Test plan

  • Before, Linux: go test -count=20 -run TestChromeDownloadsLand failed 1/20, and the attr+attachment pair failed 2/40 with ERR_ABORTED.
  • After, Linux: 0/30 for the whole test, 0/60 for attr+attachment, and 0/20 for the downloads live tests on the final commit.
  • macOS and Windows, repeated in debug CI runs: with the old flags the strays showed up once in about 29 runs per OS (Windows, the traced run); with the new flags, none in 26 runs per OS. The base rate is too low for that to prove the fix by rate alone. The cause comes from the trace: none of those files had a download event.
  • gofmt -l ., go vet ./... and go test ./... are clean.

…<a download>

Chrome reloads the page 1.46 to 1.70 seconds after an <a download> begins
(Chromium 155), and the reload aborts a navigation started before it. The
1.5-second hold sat inside that spread: the next navigate failed with
net::ERR_ABORTED 2 times in 40. The hold is now 2.5 seconds.

The live test also stopped polling at the first read naming a download,
which can still be in progress (seen on Windows). The contract is that a
read names a running download and the next one says when it ends, so the
test now polls until the download is no longer in progress.
Downloads are allowed for the whole browser, so the optimization guide's
model downloads, which run with no page and announce no download event,
landed in the user's Downloads as files named by a GUID and were never
renamed. The Windows and macOS CI runners left 4 KB to 33 MB of them next
to the six files the live test expects. Chrome now starts with those
features off.
@omartelo
omartelo force-pushed the fix/browser-downloads-flake branch from 5a7cd26 to ffde639 Compare October 28, 2026 01:01
@omartelo omartelo changed the title fix(browser): hold a download's answer past Chrome's reload after an <a download> fix(browser): fix the downloads live test flake at its three causes Oct 28, 2026
@omartelo
omartelo marked this pull request as ready for review October 28, 2026 01:01
@omartelo
omartelo merged commit 757699d into main Oct 28, 2026
7 checks passed
@omartelo
omartelo deleted the fix/browser-downloads-flake branch October 28, 2026 10:50
omartelo added a commit that referenced this pull request Oct 28, 2026
Browser.setDownloadBehavior is browser-wide, so files Chrome downloads on
its own, with no page and no download event, landed in the user's
Downloads under a GUID and were never renamed (macOS and Windows runners,
after #959 switched the optimization guide's model downloads off).

Chrome now writes into a staging folder inside the session's ephemeral
profile. Only a download a page announced moves to Downloads, under its
reserved name; anything else stays in staging and is deleted with the
profile. Across filesystems or volumes the move falls back to a copy
under a hidden .part name, renamed once whole, reusing profilestore's
copy helper and cross-device seam, now exported.
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