Repository navigation
fix(engine): remote downloads get an absolute deadline and stop before the disk fills - #7827
Conversation
…e the disk fills A download whose response declares a Content-Length re-arms its attempt timeout on every chunk, so a server that trickles just above the throughput floor was never cut off by time. Parallel downloads also had no shared limit on the disk they could fill. - Each download attempt now has a deadline that incoming data never moves: 30 minutes by default, HYPERFRAMES_MAX_DOWNLOAD_MS to change it. Passing it fails the download without a local retry. - The default per-file cap drops from 20 GiB to 8 GiB (HYPERFRAMES_MAX_DOWNLOAD_BYTES still overrides it). - Downloads keep 512 MiB free on their volume (HYPERFRAMES_DOWNLOAD_MIN_FREE_BYTES, 0 turns it off). A declared size is claimed before the body is read and counted against every parallel download on the same device, and free space is measured again every 4 MiB as bytes arrive. Free space that cannot be measured does not block. - docs/packages/engine.mdx lists the download limits and their variables.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
jrusso1020
left a comment
There was a problem hiding this comment.
Approve. Reviewed at 218fc25cf1105e79ef34555abbf90a02ec37cbca. The deadline can't be reset by incoming data, a deadline abort is non-retryable and removes the partial, and the headroom claim is released on every exit. The three nits below are wording and operator notes, not blockers.
Need: yes, the attempt timer was re-armed by every sized chunk, so a stream just above the floor was never stopped by time · Size: ok · Reuse: integerFromEnv, UrlDownloadError and the existing attempt finally are reused; the catch-block consolidation removes three copies of the telemetry call · Simpler: already minimal · Structure: fine (checked whether the claim belongs in downloadWithRetry instead; per attempt is right because each attempt has its own partial)
Risk: low for the code. The behaviour change is real for operators, since a download that ran 30+ minutes or past 8 GiB now fails without a retry; both are env-tunable and documented.
What I ran
urlDownloader*suites inpackages/engine: 120 passed.- Revert check: I restored
urlDownloader.tsfrom the base. The three new tests fail (both free-space tests and the absolute-deadline test), and the other 117 still pass. - Release check: with
headroom.release()removed from thefinally, the parallel declared-bodies test fails. Claims leaked by earlier tests on the same device push it over the minimum, so the release is covered too. - Read-through of the accounting:
claimand its measurement run synchronously, so parallel downloads in one process can't both pass on the same free space.- Bytes count as received when the chunk arrives, slightly before they reach the disk. That gap is a stream buffer, which is negligible.
- Undeclared bodies claim 0 and rely on the re-measure every 4 MiB, so N parallel downloads can overshoot the minimum by at most about N x 4 MiB.
Nits (non-blocking)
- The claims are per process.
unreceivedBytesByDeviceis module state. Two render processes on one host don't see each other's claims; each sees the other's writes only when it re-measures free space. The PR body says the check "covers parallel downloads and parallel renders on one host", and the docs say it "counts the declared sizes of all downloads running at the same time". Both read as host-wide. Suggest "in this process" in the docs line. - The deadline is per attempt. A retryable stall or a too-slow abort at minute 29 starts attempt 2 with a fresh 30 minutes. A download can therefore run about an hour wall-clock. The docs row calls it "Longest download, however fast data arrives". The PR body says "per attempt" correctly; the docs row could too.
- 512 MiB is below many hosts' own low-disk thresholds. On a container host that evicts workloads at a percentage of free disk, eviction fires long before 512 MiB is left. A short docs sentence could tell operators of shared hosts to set
HYPERFRAMES_DOWNLOAD_MIN_FREE_BYTESabove that threshold.
— Rames
Edit accuracy: accurate 267 (base branch 267), smooth 111 of thoseThe gate passes. Quarantined, measured but not gated (8)
Unstable (1)
|
|
Thanks, Rames. I fixed the PR description for nits 1 and 2 (claims are per process, and the deadline is per attempt). To keep your approval, I did not push to this branch. The docs wording for all three nits goes into a small follow-up PR, which I will open after this merges. |
* chore: release v0.9.54 * chore: release v0.9.54 notes include heygen-com#7827, heygen-com#7825, heygen-com#7845, heygen-com#7848 and heygen-com#7849 * chore: release v0.9.54 notes include heygen-com#7853 * chore: release v0.9.54 notes include heygen-com#7851 and heygen-com#7855
What
Remote media downloads (the
<video>,<audio>, image and font URLs a composition names) get three new limits:HYPERFRAMES_MAX_DOWNLOAD_MS). Incoming data never moves it. A download past it fails with atimeouterror that is not retried.HYPERFRAMES_MAX_DOWNLOAD_BYTES, unchanged name).HYPERFRAMES_DOWNLOAD_MIN_FREE_BYTES;0turns the check off). Before the body is read, a download claims its declared size, and the claim counts against every parallel download on the same device. Free space is measured again every 4 MiB received. The error is a non-retryablefilesystemerror. If free space cannot be measured, the download continues.Why
Every chunk of a response with a
Content-Lengthre-armed the attempt timeout. The only other limit was a 32 KiB/s throughput floor. So a server that streamed just above that floor with a huge declared length was never stopped by time. Several such URLs downloading in parallel, each allowed up to 20 GiB, could fill the render host's work volume.Related work
Refs #7786, which added the per-file cap, the compressed-response refusal and the throughput floor.
How
runDownloadAttemptstarts a second timer that only the end of the attempt clears.DiskHeadroomGuardtracks bytes that in-flight downloads declared but have not received, per device.fetchToPartialclaims the declared size before reading and checks headroom as bytes arrive. The attempt releases its claim infinally.catchblock now builds one error and emits telemetry once, instead of repeating the telemetry call per branch.docs/packages/engine.mdxlists the four download environment variables and their defaults.No per-render byte budget was added. It would need a budget object threaded through five producer and engine callers, and the headroom check already covers parallel downloads in one process. Separate render processes on one host see each other's writes when they measure free space again, every 4 MiB.
Why these defaults: 8 GiB holds about 20 minutes of 4K H.264 at 50 Mbps, or hours of 1080p. Finishing an 8 GiB file in 30 minutes needs about 4.6 MB/s. All three limits can be raised through the environment.
Test plan
3 new tests fail on main and pass now: a server that streams steadily above the throughput floor with a large declared length is stopped by the deadline; a declared size that would cross the free-space minimum is refused before the body is read; and parallel bodies are stopped once their combined claims cross the minimum.
The downloader tests (120) passed 3 runs in a row. An existing test that streams for over 15 minutes still passes.
Engine unit suite: 3096 pass. The same 15 tests fail on main too (they need ffmpeg and local fixtures).
Producer download-related tests: 21 vitest and 308 bun tests pass.
Engine
tsc, oxlint, oxfmt, fallow and the comment ratchet pass.Unit tests added/updated
Manual testing performed (no render run against a slow server)
Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments"