-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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: simplify server.close() behavior when closing unopened server. #34042
base: main
Are you sure you want to change the base?
Conversation
This PR seems to have gotten a little stuck. Is there anything that should be done to move further? |
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
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, some minor nits for typos
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
Seems to be stuck again. @nodejs/net, @mcollina ? |
@mkrawczuk this needs rebasing. @nodejs/tsc given this is semver-major, I kindly ask for another review. |
@mcollina resolved conflicts via the github interface. I hope this does also rebase. |
Commit Queue failed- Loading data for nodejs/node/pull/34042 ✔ Done loading data for nodejs/node/pull/34042 ----------------------------------- PR info ------------------------------------ Title net: simplify server.close() behavior when closing unopened server. (#34042) Author Mateusz Krawczuk (@mkrawczuk) Branch mkrawczuk:net_server_close_simplify -> nodejs:master Labels errors, net, semver-major Commits 5 - net: simplify server.close() behavior when closing unopened server. - Update test/parallel/test-net-server-close.js - Update test/parallel/test-net-server-close.js - Update test/parallel/test-net-server-close.js - Merge branch 'master' into net_server_close_simplify Committers 2 - Mateusz Krawczuk - GitHub PR-URL: https://github.com/nodejs/node/pull/34042 Reviewed-By: Matteo Collina Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/34042 Reviewed-By: Matteo Collina Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell -------------------------------------------------------------------------------- ✔ Last GitHub Actions successful ℹ Last Full PR CI on 2020-12-16T17:03:04Z: https://ci.nodejs.org/job/node-test-pull-request/34973/ - Querying data for job/node-test-pull-request/34973/ ✔ Build data downloaded ✖ 1 failure(s) on the last Jenkins CI run ℹ This PR was created on Wed, 24 Jun 2020 16:33:28 GMT ✔ Approvals: 3 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/34042#pullrequestreview-486914209 ✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/34042#pullrequestreview-486490387 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/34042#pullrequestreview-553860517 -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/426377355 |
Huh? There seems to be a merge conflict in Jenkins job, file |
No |
But is it a PR problem or Jenkins problem? |
This seems to not apply cleanly on master.
Can you please rebase this on top of master? |
Hmm, indeed. I have re-rebased it and now it should be all right. |
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.
This contains a lot of unrelated commits. Bad rebase/merge?
59a3a94
to
b0e2b2e
Compare
|
||
if (typeof cb === 'function') { | ||
this.once('close', cb); | ||
} |
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: This change means that the callback won't always be invoked. Isn't that considered an anti pattern?
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.
As long as callback is a function, it will be called. Or am I missing something?
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.
@ronag is right. If there is no _handle
yet the callback will not be called.
I see no use case for behavior where an error is thrown in case a callback is registered for a `close` event on a closed server. This is bizarre and unusual. Originally, this behavior was introduced along with commit 984dc05 in order to mimic net_legacy behavior. net_legacy for stdio was replaced by uv_net in Node 0.5.7 (2011 AD.). Up until commit f1dc55d, an error would be thrown synchronously if attempt has been made to close an unopen server. The change would introduce the current behavior. This is a breaking API change and should most likely be introduced in a major update.
b0e2b2e
to
b86ca35
Compare
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.
Now that I see this, I agree with @ronag. A user would expect that a callback is called.
This change is likely not correct as it is right now.
|
||
// Ensure that the close callback is not called when the server was not | ||
// previously running. | ||
server.close(common.mustNotCall()); |
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.
This is not correct. We should always call the 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.
@mcollina could you please clarify why we need to close the server if that server is not running?
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.
FWIW, I agree with Matteo. The callback here should be called in case there is any cleanup logic that is deferred to close (e.g. closing fd's). There's a non-trivial risk of breakage here and I don't see this change as being worth it now that I reconsider.
I see no use case for behavior where an error is thrown in case a callback is
registered for a
close
event on a closed server. This is bizarre and unusual.Originally, this behavior was introduced along with commit 984dc05 in order
to mimic net_legacy behavior. net_legacy for stdio was replaced by uv_net in
Node 0.5.7 (2011 AD.).
Up until commit f1dc55d, an error would be thrown synchronously if attempt
has been made to close an unopen server. The change would introduce the current
behavior.
This is a breaking API change and should most likely be introduced in a major
update.
make -j4 test
(UNIX), orvcbuild test
(Windows) passes