fix(distribution-downloader): time out on a stalled transfer instead of a slow one - #835
Open
ddeboer wants to merge 2 commits into
Open
fix(distribution-downloader): time out on a stalled transfer instead of a slow one#835ddeboer wants to merge 2 commits into
ddeboer wants to merge 2 commits into
Conversation
…of a slow one – Replace the fixed 5-minute whole-transfer budget with an idle timeout that is reset on every chunk received, so a large file that keeps flowing is never cut off while a stalled server still is – Add ‘timeout’ (idle milliseconds, default 300 000) and ‘signal’ to DownloadOptions – Cover the trickling, stalled and cancelled cases with a local HTTP server
– A 20 ms chunk interval against a 100 ms idle timeout slipped on a loaded CI runner; use 50 ms chunks against a 500 ms timeout instead
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.
LastModifiedDownloader.download()bounded the whole transfer with a fixedAbortSignal.timeout(300_000), so a 420 MB file failed whenever throughput dropped below ~1.4 MB/s.The fetch now runs under an idle timeout instead: an
AbortControllerfires when no bytes have arrived fortimeoutms (default 300 000, so a stalled server still fails after five minutes as before), and aTransformin the body pipeline restarts the timer on every chunk. Both the wait for headers and a stall midway through the body are covered.DownloadOptionsgainstimeout(idle milliseconds) andsignalfor caller-side cancellation; in both cases the partial file is removed before the error propagates.Tests use a local
node:httpserver rather than nock, whose fetch interceptor buffers the response and hides chunk timing:No data received for 100 msand leaves no file;Fix #822