-
Notifications
You must be signed in to change notification settings - Fork 30k
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
TCP socket emitted 'end' event after 'error' event #6083
Comments
@nodejs/streams Is this a bug? Documentation issue? Neither? Both? |
I would need to look into it. |
Isn’t this unspecified and depends on the individual stream? |
As @michaelnisi noted, this is unspecified and depends on the individual stream. To the best of my knowledge, there is no mechanism/enforcement in Also, That being said, I cannot reproduce the issue on node v4.4.2 (the one which output was linked in the issue), 4.8, 6.11, 8, on Mac OS X 10.12. @davepacheco is this still an issue? If that's the case, can you update the script to reproduce it, or maybe send a PR with a failing test? The script currently hang with:
|
Is there documentation that stream consumers should remove their 'close', 'end', and 'finish' listeners when 'error' happens? It seems like that makes using streams robustly a lot more complex. I'm not seeing this on OS X El Capitan (v10.11.6), but I think that just means something about the timing has changed, not that the underlying issue was OS-specific or went away. |
@davepacheco No, I do not think there is. However, most streams respect this generic pattern. Given the code we have in 8, I do not see how that can happen, as we destroy the handle synchronously in case of an internal error. I would be happy to take a look if you can reproduce anyhow. The implementations in core should not have the problem you are describing, so it is a bug in that case. It might even be OSS specific, and maybe in libuv. |
Hello |
There has been no movement on this in nearly a year and no reports of it happening again. I'm going to close it out but if any new info has surfaced or you believe this should remain open, please feel free to do so. |
Has anybody re-run the test program to see if it's still happening? |
@davepacheco The situation has changed. The script hangs:
Or I'm getting a nice abort:
This is also confirmed on master. |
Here is some output from llnode:
Do you know why it's missing the JS stacks? It's taken from master. |
New V8. llnode hasn't been updated yet. Also, the Ignition interpreter complicates frame->function mapping. In the naive solution you only see the interpreter frames, like you do with perf(1) now. @mmarchini has been working on that however, and with respectable stamina too, I may add. |
Fix in #20104. |
This PR adds _readableState.errorEmitted and add the tracking of it. Fixes: nodejs#6083
@bnoordhuis I thought llnode was handling interpreted functions 🤔 (at least on Node.js 8). Unfortunately what I've been working on will only fix Looking at the output from @mcollina though, looks like |
My bad, I was using the wrong command. Anyway, I tracked down the problem and a PR is on the way. |
This reverts commit 8f6ab9f. This PR adds _readableState.errorEmitted and add the tracking of it. Fixes: nodejs#6083 See: nodejs#20334 See: nodejs#20449
Sorry to bomb this thread but I am looking for info regarding whether a tcp connection can recover after an 'error' event is emitted. I am guessing not, but I am not really sure. Currently, if 'error' is emitted I call .end() on the current connection and try to open a entirely new one. |
Unless you are emitting error yourself, you can safely assume that the connection is gone. You don’t need to call .end(). If you want to be safe, call .destroy() |
@mcollina thanks appreciated |
@ronag do you know if this is still an issue or if this is already fixed? |
@BridgeAR: It still seems to be an issue. As far as I can tell, the fix was reverted and the follow up was closed... I haven't followed the entire history and rationale of this. @mcollina mentioned the following #20571 (comment)
But as far as I can see from master, this is still a problem, i.e. I wouldn't mind to pick up on this but would be useful if those involved so far could shime in? @mafintosh @mcollina |
@BridgeAR: Now I think this is fixed :) |
This comment has been minimized.
This comment has been minimized.
@celesteking this sort of comment is entirely unacceptable in the Node.js org. Please self-moderate and avoid these sort of comments in the future. Please consider what exactly you're trying to accomplish here and how these comments reflect on you and others in the org. |
Although it's not technically documented, a lot of code assumes that once a stream emits an 'error' event, it will not subsequently emit 'data' or 'end' events. This is pretty much necessary, because otherwise it's impossible for a stream consumer to know when a stream has come to rest and will emit no more events. I've reproduced a case where Node reliably emits an 'end' event after an 'error' event, which violates the expectations of code that assumes a stream has come to rest after 'error'.
To be really precise about where I tested it:
Works as expected on v0.10 (perhaps only because the 'end' event is emitted first):
Does not work as expected on v0.12 and later:
Here's a test case that's commented with what it's doing. I've tried to simplify it as much as possible, but since it's a race condition, it's tricky to get the timing just right.
The detailed output for each test I ran is here:
https://gist.github.com/davepacheco/84d450d2c25f6212a99a984a8f089b4c
The text was updated successfully, but these errors were encountered: