Major Changes
-
LazyFileandLazyBlobno longer extend nativeFileandBlobSome runtimes (like Bun) bypass the JavaScript layer when accessing
File/Blobinternals, leading to issues with missing content due to the lazy loading behavior.LazyFileandLazyBlobnow implement the same interface as their native counterparts but are standalone classes.As a result:
lazyFile instanceof Filenow returnsfalse- You cannot pass
LazyFile/LazyBlobdirectly tonew Response(file)orformData.append('file', file) - Passing a
LazyFile/LazyBlobdirectly toResponsewill throw an error with guidance on correct usage
Migration:
// Before let response = new Response(lazyFile) // After - streaming let response = new Response(lazyFile.stream()) // After - for non-streaming APIs that require a complete File (e.g. FormData) formData.append('file', await lazyFile.toFile())
New methods added:
LazyFile.toFile()LazyFile.toBlob()LazyBlob.toBlob()
Note:
.toFile()and.toBlob()read the entire content into memory. Only use these for non-streaming APIs that require a completeFileorBlob(e.g.FormData). Always prefer.stream()when possible.