You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
When creating a http server and piping a stream into the response, it does not flushes the content in the first write, only after the second.
importhttpfrom'http'import{PassThrough}from'stream'http.createServer((req,res)=>{res.setHeader('Content-Type','text/html; charset=utf-8')conststream=newPassThrough()stream.pipe(res)if(req.url==='/single'){stream.write('hello')}if(req.url==='/double'){stream.write('hello')stream.write(' world')}// Does not ends the stream because ending// would forcefully flush contents.}).listen(8080,()=>{console.log('http://localhost:8080')})
What is the expected behavior?
Calling localhost:8080/single would output hello and calling localhost:8080/double would still print hello world.
This behaviour is right in nodejs:
# prints hello in nodejs
curl http://localhost:8080/single -vN
* Trying 127.0.0.1:8080...
* TCP_NODELAY set* Connected to localhost (127.0.0.1) port 8080 (#0)> GET /single HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.68.0
> Accept: */*>
hello
# prints hello world in nodejs
curl http://localhost:8080/double -vN
* Trying 127.0.0.1:8080...
* TCP_NODELAY set* Connected to localhost (127.0.0.1) port 8080 (#0)> GET /double HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.68.0
> Accept: */*>* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Date: Thu, 21 Sep 2023 19:23:46 GMT
< Transfer-Encoding: chunked
<
hello world
What do you see instead?
Calling localhost:8080/single would never give any output:
# Does not prints hello
curl http://localhost:8080/single -vN
* Trying 127.0.0.1:8080...
* TCP_NODELAY set* Connected to localhost (127.0.0.1) port 8080 (#0)> GET /single HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.68.0
> Accept: */*>
Calling localhost:8080/double would give both generated output:
# Prints hello world
curl http://localhost:8080/double -vN
* Trying 127.0.0.1:8080...
* TCP_NODELAY set* Connected to localhost (127.0.0.1) port 8080 (#0)> GET /double HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.68.0
> Accept: */*>* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Date: Thu, 21 Sep 2023 19:23:46 GMT
< Transfer-Encoding: chunked
<
hello world
Additional information
No response
The text was updated successfully, but these errors were encountered:
arthurfiorette
changed the title
http.ServerResponse only flushes after second writehttp.ServerResponse only flushes content automatically to network after second write call
Sep 21, 2023
What version of Bun is running?
1.0.2+37edd5a6e389265738e89265bcbdf2999cb81a49
What platform is your computer?
Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
When creating a http server and piping a stream into the response, it does not flushes the content in the first write, only after the second.
What is the expected behavior?
Calling
localhost:8080/single
would outputhello
and callinglocalhost:8080/double
would still printhello world
.This behaviour is right in nodejs:
What do you see instead?
Calling
localhost:8080/single
would never give any output:Calling
localhost:8080/double
would give both generated output:Additional information
No response
The text was updated successfully, but these errors were encountered: