-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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: use _final
instead of on('finish')
#18608
Conversation
lib/net.js
Outdated
return self._handle.shutdown(req); | ||
} | ||
|
||
// the user has called .end(), and all the bytes have been | ||
// sent out to the other side. | ||
function onSocketFinish() { | ||
Socket.prototype._final = function(cb) { | ||
// If still connecting - defer handling 'finish' until 'connect' will happen |
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.
Nit: I'd remove handling 'finish'
as we are no longer handling the 'finish'
event.
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.
@lpinca done! And thanks for the reviews, it’s really helpful to talk this through with you!
@addaleax please always trigger a CI after opening a PR :-) |
I usually wait until the first review or so, since the PR likely needs to be updated after it anyway. |
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.
Good work!
@@ -55,6 +55,8 @@ function undestroy() { | |||
this._writableState.destroyed = false; | |||
this._writableState.ended = false; | |||
this._writableState.ending = false; | |||
this._writableState.finalCalled = false; | |||
this._writableState.prefinished = false; |
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.
can you add a unit test for those? Maybe also place them in a separate commit, if we want to backport them separately.
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.
@mcollina Do you know where those tests are? In any case, these lines are tested in the sense that tests do fail without them...
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 need test that can be run as part of readable-stream
.
Here are the current tests:
test/parallel/test-stream-duplex-destroy.js
test/parallel/test-stream-readable-destroy.js
test/parallel/test-stream-transform-destroy.js
test/parallel/test-stream-writable-destroy.js
Shutting down the connection is what `_final` is there for.
@mcollina Thanks for the pointer, done! |
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.
LGTM
Landed in 906bbef |
@addaleax it seems this landed without metadata. |
@lpinca I’ve force-pushed that mistake away, thanks for pointing it out. |
Shutting down the connection is what `_final` is there for. PR-URL: #18608 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Shutting down the connection is what `_final` is there for. PR-URL: nodejs#18608 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Shutting down the connection is what `_final` is there for. PR-URL: nodejs#18608 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Shutting down the connection is what `_final` is there for. PR-URL: nodejs#18608 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Shutting down the connection is what `_final` is there for. PR-URL: #18608 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Shutting down the connection is what `_final` is there for. PR-URL: #18608 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Shutting down the connection is what
_final
is there for.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
net