It would utilize a optimized stream pipeline to prevent memory leaks, resolving issues where large video fetches fail to release memory.
Memory Leak with Blob/ArrayBuffer and Bun's Garbage Collection bun.mp4
Instead of manually calculating CHUNK_SIZE and Content-Range headers with fs.statSync (as currently done in Express), Bun.serveVideo would automatically handle this based on the Range request header. It would utilize a optimized stream pipeline to
Bun does not support streaming videos with range requests #10440 bun.mp4
// Proposal for new feature Bun.serve({ async fetch(req) { const file = Bun.file("./bun.mp4"); // Optimized built-in method return new Response(await Bun.serveVideo(file, req)); }, }); Use code with caution. Copied to clipboard