-
Notifications
You must be signed in to change notification settings - Fork 7.3k
dgram: make .send cb act as an "error" event handler. #7738
Conversation
|
||
if (self.listeners('error').length) { | ||
self.emit('error', ex); | ||
} |
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.
Convention is to drop the quotes for one-line if statements.
LGTM, no comments. An observation about the review process: it's usually easier when you push fix-up commits to your branch rather than squashing straight away. When you squash, GH tends to hide comments from previous review rounds and that sometimes makes it difficult to track the flow of the discussion. Once the review is done however, you can squash and land at will. |
Changes API, but introduces no documentation! |
callback(ex); | ||
|
||
if (self.listeners('error').length) | ||
self.emit('error', ex); |
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.
Isn't this redundant, can't we just rely upon the return value from self.emit
to determine if this was handled?
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.
If we emit and there's no error listener, the error will be thrown. This check explicitly prevents that if there's 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.
right -- that part of the api -- sigh sorry
I concur with @sam-github that we should clarify here where and when errors will be handled in this way |
Just to clarify, missing changes to the docs is what's holding up this PR? |
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes nodejs#4846.
Putting some more though on this one, I still think that if there is a callback, then the error should not be emitted, as they will have to 'trap' that error and ignore it, causing the exact same issue described above. |
I think we should break compatibility in node v3.x, or else have a different send that does the right thing. |
I agree with @sam-github. Do you think it might make sense to send a PR to io.js, or I should wait after the merge happens? |
I don't think its worth waiting, and the io.js repo is going to move, to my knowledge, to the new org. |
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is no callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based of @chrisdickinson nodejs/node-v0.x-archive#7738. Discussion in nodejs/node-v0.x-archive#4846.
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is no callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based of @chrisdickinson nodejs/node-v0.x-archive#7738. Discussion in nodejs/node-v0.x-archive#4846.
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is no callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based of @chrisdickinson nodejs/node-v0.x-archive#7738. Discussion in nodejs/node-v0.x-archive#4846.
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is no callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based of @chrisdickinson nodejs/node-v0.x-archive#7738. Discussion in nodejs/node-v0.x-archive#4846.
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes: nodejs/node-v0.x-archive#4846 PR-URL: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is a callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based on nodejs/node-v0.x-archive#7738, which landed in 77266d7. Fixes: nodejs/node-v0.x-archive#4846 Refs: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Closing this. The fix can be back ported from nodejs/node@77266d7 and nodejs/node@90daf87. |
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes: nodejs/node-v0.x-archive#4846 PR-URL: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is a callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based on nodejs/node-v0.x-archive#7738, which landed in 77266d7. Fixes: nodejs/node-v0.x-archive#4846 Refs: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes: nodejs/node-v0.x-archive#4846 PR-URL: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is a callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based on nodejs/node-v0.x-archive#7738, which landed in 77266d7. Fixes: nodejs/node-v0.x-archive#4846 Refs: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes: nodejs/node-v0.x-archive#4846 PR-URL: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is a callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based on nodejs/node-v0.x-archive#7738, which landed in 77266d7. Fixes: nodejs/node-v0.x-archive#4846 Refs: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes: nodejs/node-v0.x-archive#4846 PR-URL: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is a callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based on nodejs/node-v0.x-archive#7738, which landed in 77266d7. Fixes: nodejs/node-v0.x-archive#4846 Refs: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes: nodejs/node-v0.x-archive#4846 PR-URL: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is a callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based on nodejs/node-v0.x-archive#7738, which landed in 77266d7. Fixes: nodejs/node-v0.x-archive#4846 Refs: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes: nodejs/node-v0.x-archive#4846 PR-URL: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is a callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based on nodejs/node-v0.x-archive#7738, which landed in 77266d7. Fixes: nodejs/node-v0.x-archive#4846 Refs: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes: nodejs/node-v0.x-archive#4846 PR-URL: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is a callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based on nodejs/node-v0.x-archive#7738, which landed in 77266d7. Fixes: nodejs/node-v0.x-archive#4846 Refs: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This allows users to provide a callback that handles potential errors resulting from a `socket.send` call. The original behavior of emitting the error event on the socket is preserved. Fixes: nodejs/node-v0.x-archive#4846 PR-URL: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Modifies the dgram send() method to not emit errors when a DNS lookup fails if there is a callback. Given that the same UDP socket can be used to send messages to different hosts, the socket can be reused even if one of those send() fails. This slightly changes the behavior of a stable API, so that it behaves as users would expect to. This is based on nodejs/node-v0.x-archive#7738, which landed in 77266d7. Fixes: nodejs/node-v0.x-archive#4846 Refs: nodejs/node-v0.x-archive#7738 PR-URL: #1796 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This allows users to provide a callback that handles potential
errors resulting from a
socket.send
call. The original behaviorof emitting the error event on the socket is preserved.
Fixes #4846.