Repository navigation
fix(download): pipe the body instead of sendStream - #282
Merged
Merged
Conversation
h3's sendStream web-stream path calls res.write() without waiting for drain and never notices the client hanging up. A slow client made the server buffer the whole entry in socket write buffers (OOM with a few concurrent restores, #274), and an aborted download kept draining the backend read and held its reader lease until expiry. stream.pipeline paces the read to the socket and destroys the source on close, which releases the lease. Co-authored-by: Peter Svensson <peter@sparetimecoders.com> Co-authored-by: Rui Chen <rui@chenrui.dev> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 23, 2026
This was referenced Oct 24, 2026
Open
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #270 so it can land independently of Range support.
h3's
sendStreamweb-stream path callsres.write()without waiting fordrainand doesn't notice the client going away:stream.pipeline(stream, res)paces the read to the socket and destroys the source on close, which releases the lease through the existingclosehandler.ERR_STREAM_PREMATURE_CLOSEis logged at debug.The new case in
tests/proxy-backpressure.test.ts(from @chenrui333) mounts the real route in-process and pauses the client after the first chunk. AgainstsendStream: ~533 MB queued in the response. Withpipeline: under 1 MiB.Closes #274
Co-authored-by: @peter-svensson @chenrui333
🤖 Generated with Claude Code