dgram: don't swallow bind errors when callback is provided#62602
Open
armanmikoyan wants to merge 1 commit intonodejs:mainfrom
Open
dgram: don't swallow bind errors when callback is provided#62602armanmikoyan wants to merge 1 commit intonodejs:mainfrom
armanmikoyan wants to merge 1 commit intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
60c4c3a to
6624c6f
Compare
Signed-off-by: armanmikoyan <arman.mikoyan1@gmail.com>
6624c6f to
4b5f804
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
dgram: don't swallow bind errors when callback is provided
When
Socket.prototype.bind()is called with a callback, the internalcleanup listener is registered on
'error', which counts as an errorhandler and silently swallows bind errors (e.g.
EADDRINUSE) when nouser error handler is attached.
This switches to
EventEmitter.errorMonitorfor the cleanup listener,matching the pattern already used in the
enqueue()function(
lib/dgram.js:571). This ensures bind errors properly propagate asunhandled errors while still performing listener cleanup.
Setup — a socket already bound to port 5000
No callback, no
listeningevent — error surfaces (correct)Using
listeningevent — error surfaces (correct)Using callback — error silently swallowed (bug)
All three examples do the same thing — bind to a port already in use.
The first two properly throw, but the third silently swallows the error
just because a callback was passed to
bind().After this fix, all three cases properly surface the error.