Repository navigation
emit after 'error' #28710
Description
Activity
- addedstreamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
on Jul 28, 2019 ping @mcollina
emit()is a leaky abstraction: there is nothing stopping anybody to call it and emit an event. The individual cases should be fixed if they do not cause too many regressions.@ronag I was wondering if it would be okay to allow 'error' events as well? Like the one here. Throwing before all subsequent errors are thrown would prevent those error logs from being shown.
@ronag I was wondering if it would be okay to allow 'error' events as well? Like the one here.
In at least streams we don't want/allow multiple error events.
I see. So are we talking about different behaviour for different modules (subsequent errors not allowed in streams but allowed in crypto (or similar ones))?
I see. So are we talking about different behaviour for different modules (subsequent errors not allowed in streams but allowed in crypto (or similar ones))?
Yea, I guess so. I would rather it would be consistent everywhere but achieving that is a high goal. I think we should start focusing on making it sensible, e.g.
- No more events after
'close' - No more "logic" events after
'error'
etc...
Reacted by Pranshu Srivastava- No more events after
Here is an updated list based on master in case you want to have a go at it https://gist.github.com/ronag/3c4fdf8f73e2671efa8b9456d7bc4746
I think all of the most important issues with post
'error'events have been resolved or has PR's now. Except for:
'close', 'exit', 'disconnect', 'removeListener', 'unpipe', 'error'which I think is ok.Next step (if any) would be to ensure
'error'is only emitted once and'close'is always last.There is work left to do on events after
'close'https://gist.github.com/ronag/c733ec3df54350964f2ead7dec6590e0- added a commit that references this issue
on Mar 17, 2020 - added 3 commits that reference this issue
on Mar 18, 2020 - added 2 commits that reference this issue
on Mar 30, 2020 - added 2 commits that reference this issue
on Apr 22, 2020
I believe the events allowed to be emitted after
errorshould be rather limited.Based on the test suite I've found the following exceptions:
exit,disconnectandclose, should be ok.unpipe, maybe ok?I've fixed some:
#28709
#28708
#28711
Then there are a lot of possible cases that might need fixing:
https://gist.github.com/ronag/b5728ae5db305abaff9955da5b47a5c9
I've found these by updating
EventEmitter.prototype.emitwith:Is this worth to further look into?