Skip to content

Handle backpressure when streaming file responses#469

Open
unprolix wants to merge 2 commits intomainfrom
jjb-response-backpressure
Open

Handle backpressure when streaming file responses#469
unprolix wants to merge 2 commits intomainfrom
jjb-response-backpressure

Conversation

@unprolix
Copy link
Collaborator

Summary

  • Check the return value of res.write() when streaming large files
  • Wait for the drain event before continuing when socket buffer is full
  • Prevents unbounded memory accumulation when serving large files to slow clients

Test plan

  • Serve large file to artificially throttled client, verify server memory stays bounded
  • Serve same file to multiple slow clients simultaneously, verify no memory spike
  • Serve file to fast client, verify no performance regression
  • Existing unit tests pass
  • Linter passes

Jeremy Bornstein added 2 commits January 13, 2026 05:53
Check the return value of res.write() and wait for the 'drain' event
before continuing when the socket buffer is full. This prevents
unbounded memory accumulation when serving large files to slow clients.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant