bun icon indicating copy to clipboard operation
bun copied to clipboard

Response doesn't stream when `Transfer-Encoding` is set to `chunked` in express.js

Open noway opened this issue 2 years ago • 0 comments

What version of Bun is running?

0.5.6

What platform is your computer?

Darwin 22.2.0 arm64 arm

What steps can reproduce the bug?

  1. Run repro script:
curl https://gist.githubusercontent.com/noway/7097e86dc5650a762b156a63e43ff6d7/raw/da6c5a8cf31bb4b33ed314dfd71c15bf9eb920e9/bun-express-streaming-response-bug.sh | bash
  • Alternatively, go to https://gist.github.com/noway/7097e86dc5650a762b156a63e43ff6d7 and copy-paste the script into Terminal.
  1. Run curl localhost:3001 in Terminal
  2. Run curl localhost:3002 in Terminal
  3. See the difference between step 2 and step 3. Port 3002 (node) is streaming. Port 3001 (bun) is not streaming.

What is the expected behavior?

The expected behaviour is for bun (port 3001) to stream (display the output line-by-line, waiting 300 ms in-between every line) just like node (port 3002) does.

What do you see instead?

Bun doesn't stream, it spits out the response as a whole when res.end() is called.

Additional information

N/A

noway avatar Feb 18 '23 11:02 noway