Skip to content

fix(distribution-downloader): time out on a stalled transfer instead of a slow one - #835

Open
ddeboer wants to merge 2 commits into
mainfrom
fix/download-idle-timeout
Open

fix(distribution-downloader): time out on a stalled transfer instead of a slow one#835
ddeboer wants to merge 2 commits into
mainfrom
fix/download-idle-timeout

Conversation

@ddeboer

@ddeboer ddeboer commented Sep 8, 2026

Copy link
Copy Markdown
Member

LastModifiedDownloader.download() bounded the whole transfer with a fixed AbortSignal.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 AbortController fires when no bytes have arrived for timeout ms (default 300 000, so a stalled server still fails after five minutes as before), and a Transform in the body pipeline restarts the timer on every chunk. Both the wait for headers and a stall midway through the body are covered. DownloadOptions gains timeout (idle milliseconds) and signal for caller-side cancellation; in both cases the partial file is removed before the error propagates.

Tests use a local node:http server rather than nock, whose fetch interceptor buffers the response and hides chunk timing:

  • a body that trickles in over 200 ms with a 100 ms idle timeout completes;
  • a body that stalls fails with No data received for 100 ms and leaves no file;
  • an aborted caller signal cancels the download.

Fix #822

…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
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.

distribution-downloader: the fixed 5-minute timeout aborts large downloads

1 participant