Preview resources have a local lifetime
A gallery that repeatedly downloads large videos can retain substantial browser memory if every preview URL remains live. Revoking too early can break playback or a download action. The right boundary is the lifetime of the actual consumer, not merely completion of fetch.
What to do next
- 01
Track URL ownership
Associate each created object URL with its preview component or a reference-counted media cache. Avoid creating a new URL during every render, and distinguish several viewers sharing one blob from unrelated downloads.
- 02
Release at the right boundary
When replacing or closing a preview, detach the media source and revoke the URL after the old consumer no longer needs it. Keep new and old URLs distinct during transitions so cleanup cannot revoke the current preview.
- 03
Exercise repeated navigation
Open and close many gallery items, replace one item while it plays, and navigate away mid-download. Verify cleanup on errors and unmounting, while reopening an item obtains a fresh preview from the private delivery route.
A concrete example
Illustrative example: opening clip A creates one object URL. Switching to clip B releases A after its player detaches, while B keeps its own live URL. Returning to A creates a fresh browser preview rather than reusing a revoked reference.
Run the local counterexample
Local runtime fixture, executed November 16, 2026. No AISwapLab request, payment or model generation was made.
Recorded runtime: v24.16.0. Run the complete script below using that runtime or record the version and changed behavior in your own environment. The script uses synthetic data and temporary resources only.
const blob = new Blob(['local preview bytes'],{type:'text/plain'});
const url = URL.createObjectURL(blob);
const before = await (await fetch(url)).text();
URL.revokeObjectURL(url);
let after;
try {await fetch(url);after='unexpectedly fetched';}
catch(error) {after=error.name;}
console.log(JSON.stringify({scheme:url.split(':')[0],before,reFetchAfterRevoke:after,
retainedBlobStillReadable:await blob.text()}));
Actual output from this run
{
"scheme": "blob",
"before": "local preview bytes",
"reFetchAfterRevoke": "TypeError",
"retainedBlobStillReadable": "local preview bytes"
}Use the result within its scope
The local URL was readable before revocation and failed on a new fetch afterward; the retained Blob object still returned its bytes. Revocation is not a deletion request to a storage provider and does not erase every reference to the data. Keep durable project identity separately and obtain a new authorized preview when the consuming view needs one.
Observed on Node 24, using a local blob scheme with no network. It is not a browser memory, garbage-collection, mobile playback or physical-device test. The linked general Node documentation may describe a later documentation release; the recorded execution version controls this observation.
Before you call it ready
- URLs are not created during every render.
- Unmount cleans up abandoned previews.
- A replaced player keeps the new source working.
When to stop or choose another method
Stop storing blob URLs as permanent project links; persist a task or asset reference that can obtain a fresh authorized preview.
