mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 03:48:56 +00:00
When writing a Response or Request with a locked body (streaming) to a file using Bun.write(), the operation would hang indefinitely. This occurred because the locked body was never converted to a ReadableStream and piped to the file destination. The fix ensures that: 1. Locked body values are converted to ReadableStreams via toReadableStream() 2. The resulting ReadableStream is piped directly to the file using pipeReadableStreamToBlob() 3. This approach works for both regular files and S3 destinations 4. The correct number of bytes written is now returned This resolves hangs in three scenarios: - Writing custom JS ReadableStreams wrapped in Response - Writing Response bodies from fetch() wrapped in new Response - Writing teed ReadableStreams to files