-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: noop destroyed socket #30839
net: noop destroyed socket #30839
Conversation
b82e63a
to
0013206
Compare
_write and _read can be called from 'connect' after Socket.destroy() has been called. This should be a noop. Refs: nodejs#30837
@@ -571,7 +572,11 @@ Socket.prototype._read = function(n) { | |||
|
|||
if (this.connecting || !this._handle) { | |||
debug('_read wait for connection'); | |||
this.once('connect', () => this._read(n)); | |||
this.once('connect', () => { | |||
if (!this.destroyed) { |
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.
_handle.onread
is already set to a noop after destroy so I don't think this is needed. Also 'connect'
should not be emitted if the socket is destroyed while connecting.
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.
Hm, I see. I can remove this. I still kind of like it since it makes it more explicit.
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.
It would be code that is impossible to cover with tests and this is already explicit
Lines 1106 to 1108 in cf5ce2c
if (self.destroyed) { | |
return; | |
} |
@lpinca: given your feedback this PR doesn't seem to do anything. However, we do have a different bug. The callback for |
I'm fine with either as long as it's consistent and documented. |
_write and _read can be called from 'connect' after
Socket.destroy() has been called. This should be a noop.
Refs: #30837
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes