dgram: don't swallow bind errors when callback is provided - #62602
Conversation
|
Review requested:
|
60c4c3a to
6624c6f
Compare
Signed-off-by: armanmikoyan <[email protected]>
6624c6f to
4b5f804
Compare
Ethan-Arrowood
left a comment
There was a problem hiding this comment.
This seems appropriate to me. Even if a fix, this is a notable change in behavior. I believe notable-change is warranted at least. I'm not sure about semver. I don't want to tag all of the TSC, but I'll see if http/net folks have any input as the dgram subsystem is relatively close to those.
|
cc @nodejs/net @nodejs/http |
|
No, I think this is just a bug fix |
|
@mcollina I can't access the CI logs. Could someone let me know if the failures are related to my changes or just flaky? Happy to fix them if needed, or a re-run would be appreciated if they're unrelated. |
|
CI failure looks unrelated to me; its a sqlite-backup flake and some rebase infra issue. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Landed in 97c7e32 |
Signed-off-by: armanmikoyan <[email protected]> PR-URL: #62602 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Gürgün Dayıoğlu <[email protected]>
Signed-off-by: armanmikoyan <[email protected]> PR-URL: #62602 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Gürgün Dayıoğlu <[email protected]>
Signed-off-by: armanmikoyan <[email protected]> PR-URL: #62602 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Gürgün Dayıoğlu <[email protected]>
Signed-off-by: armanmikoyan <[email protected]> PR-URL: #62602 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Gürgün Dayıoğlu <[email protected]>
Signed-off-by: armanmikoyan <[email protected]> PR-URL: #62602 Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Gürgün Dayıoğlu <[email protected]>
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.