Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test but I think this still does not prevent the
'error'event from being emitted multiple times. Assume thatsocket.destroy(err)is called twice.First call will wait for this callback to be called and emit
'error'and'close'when that happens.Second call will find
_readableState.destroyedset totruebut_writableState.errorEmittedis not set totrueyet as that will happen when this callback if invoked, so another'error'event will be emitted.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But isn't that true for any stream? If you call destroy twice with error it will emit error twice... I would say the problem is in the destroy impl then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's emitted only once
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Twice like this...
it's only once if you call
cbsynchronously. Which doesn't seem like the usual case or we wouldn't have a callback?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The callback on destroy is not a public api. It is used only internally.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused... https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_constructor_new_stream_writable_options and https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_writable_destroy_err_callback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, sorry, I was referring to https://nodejs.org/api/stream.html#stream_writable_destroy_error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(We should fix that error being emitted more than once in streams imo.)