Repository navigation
test(cli): a stalled download times out once its bytes are on disk, not on a clock - #6750
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 0 important · 0 nits · head d68e9113
Scope
- The fake host now waits on the same thing the code under test reads.
writeBody's failure path waits for the file stream toclose, then setsreceived = fileSize(tmp), so onceonDisksees the bytes the attempt counts them. For the host that ignores the range, both an early and a late timeout leavereceived ≤ 300, so the test reaches the same give-up path either way. - Reproduced locally. With
fs.opendelayed by 50 ms (the stream still opening, its chunk buffered and dropped on destroy), main's two stalled-download tests fail with "Download timed out after 10ms" and this head passes. Delayingfs.writealone did not reproduce it, because a write already in flight finishes beforeclose. Full file: 31/31. - Required
Tests on windows-latest(engine-cli included) and the rest of CI are green on this head.
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.
What
The stalled-download tests' fake host no longer times out on a clock. Its idle timeout fires once the bytes the connection delivered are in the partial file, so the tests no longer race the disk.
Why
Tests on windows-latest: engine-clifailed on main and in the merge queue withresumes a download that stalls at the same byte count on every connection: "Download timed out after 10ms". When an attempt fails, the download counts its progress as the bytes that reached disk. The fake host's 10 ms timer could fire while a Windows runner's file write was still pending, so the attempt showed no progress and the download gave up, which is the test's other path.gives up when a retry brings no new byteshad the same race on its first attempt.Related work
The tests came with the download-resume work (#6649, #6694). No change to
download.ts.How
stallingHosttakes the partial file's path. Its fake request keeps the timeout callback and calls it once the file holds the bytes sent on that connection, checking once per event-loop turn. With a range-honouring host the partial file only grows, so that wait is exact. With a host that ignores the range, the retry rewrites from byte 0 and cannot show progress whenever the stall lands, which is the outcome that test asserts.Test plan
fails without the fix: with every file write delayed 50 ms (a slow disk), main's two stalled-download tests fail; with this change they pass. On Windows runners main's version failed in #6744's run and in merge-group run 40881679648.
afterFailure'sprogressed -> continuerule removed, the stalled-download tests fail.download.test.ts: 31 of 31; the stalled-download group 3 runs in a row. Format, lint and commit hooks clean.