fix(engine): make remote video downloads atomic#2774
Open
jrusso1020 wants to merge 1 commit into
Open
Conversation
jrusso1020
force-pushed
the
fix/atomic-video-download-retry
branch
from
July 25, 2026 07:39
02e2c45 to
5f05376
Compare
| // lgtm[js/file-access-to-http] — every redirect hop is fetched manually | ||
| // only after the HTTPS/private-host guard above; automatic redirect | ||
| // following is disabled so an allowed host cannot bounce into IMDS. | ||
| const response = await fetch(currentUrl, { |
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.
Summary
Root cause
The previous downloader wrote directly to the final cache path and cleared its timeout as soon as response headers arrived. A body timeout or mid-stream socket reset could therefore leave a truncated file at a path that later extraction treated as complete. The downstream symptom was zero extracted frames followed by a generic video coverage failure.
Retry policy
Exactly one retry is allowed for 408, 429, 5xx, timeouts, empty successful bodies, and network/socket failures including nested Undici errors. Cancellation, 404/410, other 4xx, URL/redirect validation errors, and filesystem errors are not retried.
Security and portability
mkdtempSynccreates an unguessable same-filesystem staging directory; exclusive writes plus atomic rename prevent symlink planting and partial publicationredirect: "manual"and every resolvedLocationis revalidated before the next request, blocking redirect-to-private/IMDS bypassesfsync, which preserves flush semantics and avoids WindowsEPERMRollout safety
This does not change render-plan schema, Plan v1 artifacts, chunk routing, or distributed rendering semantics. It is suitable for the candidate sidecar lane first; stable can remain pinned while we compare video extraction and coverage failures.
Validation