mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 13:22:07 +00:00
Fix a race condition in the node:https ClientRequest streaming body where chunks could be lost when using request-promise + fs.createReadStream() for multipart uploads. The issue occurred because: 1. When multiple chunks were pushed to kBodyChunks between Promise resolutions in the async generator, only one chunk was yielded per iteration 2. When the request finished (self.finished = true), any remaining chunks in kBodyChunks were not yielded before the generator returned This fix adds two safety loops: 1. After each Promise resolution, yield any remaining chunks that were pushed 2. After the main loop exits, yield any chunks that remain in the buffer This is particularly important for HTTPS connections where the TLS handshake delay can cause timing differences between when data is piped and when it's consumed by the stream. Fixes #26638 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>