Repository navigation
remotion: Fix prefetch() cleanup for shared assets - #12591
Merged
Merged
Conversation
Contributor
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Shared-prefetch registry —
activePrefetchestracks completed prefetches persrcWithoutHashas aMap<symbol, string>, using a per-callprefetchIdso two handles for the same asset no longer clobber each other. - Non-destructive cleanup —
free()now deletes only its own entry, restores another completed URL intopreloadswhen one remains, and drops the preload only when the last entry goes; thep[src] === remainingUrlshort-circuit avoids needless re-renders. - Idempotent
free()— thecanceledguard moved to the top, making repeatedfree()calls harmless. - Cancellation blob revoke — a blob URL created after
free()raced the completion path is revoked before registration instead of leaking. - Docs —
prefetch.mdxfree()wording fixed and the independent-cleanup behavior documented as<AvailableFrom v="4.0.539" inline />, matching the next patch aboveVERSION = '4.0.538'.
I traced the cleanup paths and found the bookkeeping consistent: for blob URLs each createObjectURL string is unique, so [...values()].pop() never restores an already-revoked URL; for base64 the values are identical strings and no revoke is performed, so the short-circuit is equivalent to a rewrite. Mixed base64/blob and reversed completion orders also restore a live URL owned by a still-active handle. bun test src/test/prefetch.test.ts passes on the branch.
deepseek-v4.1-flash | 𝕏
This branch was successfully deployed
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.

When two components prefetched the same asset, either component's
free()removed the shared preload, causing the other component to fetch the original URL again despite having a completed prefetch.Track completed prefetches by handle identity and keep the most recently completed live URL active. Freeing a handle releases only its own URL, restores another completed prefetch when needed, and becomes harmless when called again. This works for identical base64 URLs as well as blob URLs. Also release a blob URL if cancellation happens just before it is registered.
Document the independent cleanup behavior for 4.0.539.
Validation:
prefetch()checks passed for both cleanup orders, identical base64 URLs, mixed methods, reversed completion, repeated cleanup, hash aliases, cancellation, and failed sibling requests.Preview