-
Notifications
You must be signed in to change notification settings - Fork 30.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: rename internal functions for readability #11796
Conversation
lib/net.js
Outdated
|
||
Server.prototype._setUpListenHandle = setUpListenHandle; | ||
Server.prototype._listen2 = setUpListenHandle; // legacy alias |
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.
Not sure if _listen2
should be simply removed (would anyone rely on a method with a name like this?)..._setUpListenHandle
can be put into a internal symbol, though.
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.
https://github.com/search?l=JavaScript&p=1&q=%22._listen2%22&ref=searchresults&type=Code&utf8=%E2%9C%93 shows a few uses, but nothing major I suppose.
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.
Removing it would likely (unfortunately) require a semver-major and a deprecation cycle.
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.
@jasnell I'll keep it and make a following doc-deprecate PR.
lib/net.js
Outdated
|
||
Server.prototype._listen2 = function(address, port, addressType, backlog, fd) { | ||
debug('listen2', address, port, addressType, backlog, fd); | ||
function setUpListenHandle(address, port, addressType, backlog, fd) { |
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 may just be me but setUpListenHandle
looks odd. Perhaps setupListenHandle
would be better?
lib/net.js
Outdated
exclusive = !!exclusive; | ||
|
||
if (!cluster) cluster = require('cluster'); | ||
|
||
if (cluster.isMaster || exclusive) { | ||
self._listen2(address, port, addressType, backlog, fd); | ||
if (cluster.isMaster || exclusive) { // Will create a new handle |
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 this comment be moved to the next line on it's own?
lib/net.js
Outdated
return this; | ||
} | ||
|
||
throw new Error('Invalid listen argument: ' + util.inspect(options)); | ||
}; | ||
|
||
function lookupAndListen(self, port, address, backlog, exclusive) { | ||
require('dns').lookup(address, function doListening(err, ip, addressType) { | ||
require('dns').lookup(address, function doListen(err, ip, addressType) { |
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.
I know it was already like this, but can you split this into two lines?
const dns = require('dns');
dns.lookup(...)
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 with a few suggestions
Aside: the new relic agent and the opbeat agent are wrapping |
979c5e2
to
e382b3d
Compare
Addressed comments from @jasnell . I decided to leave New CI: https://ci.nodejs.org/job/node-test-pull-request/6995/ |
Given that |
@jasnell Yeah...thinking again if |
af8de08
to
307480f
Compare
I just realized if we stopped calling New CI: https://ci.nodejs.org/job/node-test-pull-request/7015/ |
@joyeecheung thanks for thinking of the APM vendors 😄 As far as I can see you ended up aliasing Both New Relic and Opbeat (and most likely other vendors as well) base our patching of Node core on the async-listener module. I'm not sure how many APM vendors merge in new changes from this module though (as we usually have to modify the module quite a bit to optimize the performance to our use-case). But in any case I've opened a PR in async-listener (othiym23/async-listener#103) to make sure it patches I fear that the new code is a little harder to understand than the old, since the code is now calling a legacy alias, which to outsiders might seem pretty weird. So the reason why I want to get this into the hands of APM vendors ASAP is because I fear that it's just a matter of time before someone cleans up the code or by accident just calls |
* Rename listen to listenInCluster * Rename _listen2 to _setupListenHandle * Remove _listen since it's a one-liner only used in one place * Correct comments in server.listen
307480f
to
a24ab8f
Compare
git am failed due to conflicts...rebased and last CI before landing: https://ci.nodejs.org/job/node-test-pull-request/7151/ |
Landed in 0ea4570, thanks! |
* Rename listen to listenInCluster * Rename _listen2 to _setupListenHandle * Remove _listen since it's a one-liner only used in one place * Correct comments in server.listen PR-URL: #11796 Reviewed-By: James M Snell <jasnell@gmail.com>
EDIT: posted the wrong commit hash, it's 0ea4570 |
* Rename listen to listenInCluster * Rename _listen2 to _setupListenHandle * Remove _listen since it's a one-liner only used in one place * Correct comments in server.listen PR-URL: nodejs#11796 Reviewed-By: James M Snell <jasnell@gmail.com>
this should likely be backported |
ping |
Depends on #11667 which is don't-land-on-v6.x |
The current namings are a bit confusing and hard to be searched for.
Also
Socket.prototype.listen
doesn't seem to be tested nor documented, added a FIXME.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
net