-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'close' event called before 'end' in paused stream #19166
Comments
|
@rohanraj7316 but according to the docs, once the |
cc @nodejs/streams |
can you share the link pls @DiegoTUI |
@rohanraj7316 you mean the link to the docs? Here it is: |
Since we have multiple phases in the Node js event loop. When we say event loop there are multiple phases of Event Loop cycle |
@rohanraj7316 If I understood correctly, you are suggesting that the fact that the
If the |
I think this is a bug. It also goes back to Node 4 at least. |
Currently the writable side of the socket is closed as soon as `UV_EOF` is read regardless of the state of the socket. This allows the handle to be closed before `'end'` is emitted and thus `'close'` can be emitted before `'end'` if the socket is paused. This commit prevents the handle from being closed until `'end'` is emitted ensuring the correct order of events. Fixes: nodejs#19166
I believe I've found an akward behaviour of a stream in paused mode using the
net
module. In some specific cases, when the source socket ends, theclose
event is called before theend
event in the destination socket. I've been able to reproduce it simulating the callback queue with nested setImmediates.Server
I've tried with two clients.
Client 1 (bash)
$ echo EVENT | nc localhost 1100
Client 2 (node)
It consistently "fails" with both, "fail" meaning that the
close
event is called before theend
event. According to the documentation this should never happen.NOTE: The number of
setImmediate
s that you need to nest in order to make it "fail" may vary depending on your environment.The text was updated successfully, but these errors were encountered: