-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
tls: prefer path over port in connect #14564
Conversation
Is this semver-major? |
Yes most likely semver major. |
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 CITGM run.
ping @nodejs/ctc |
If it is documented that path is preferred over port and it is also consistent towards net.connect(), I would argue it is a semver-patch. Especially as the options are not compatible with each other and should normally not coexist in the first place. |
path: unixServer.address(), | ||
port: tcpServer.address().port, | ||
host: 'localhost', | ||
rejectUnauthorized: 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.
Nit: extra comma at the end.
}); | ||
} | ||
|
||
testLib(net, () => testLib(tls, common.mustCall())); |
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.
Callback for net
case also should have common.mustCall
}); | ||
} | ||
const server = lib.createServer(...args); | ||
server.listen(tcp ? 0 : common.PIPE, () => cb(server)); |
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.
common.mustCall
for this callback also?
rejectUnauthorized: false, | ||
}, () => { | ||
const bufs = []; | ||
client.on('data', common.mustCall((d) => { |
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.
Generally, data
handler will be called multiple times. If we are sure that it will be called only once, then bufs
need not be an array, 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.
I don't think there's a reason to be sure it will be only called once, is there?
assert.strictEqual(`${libName(lib)}:${unixServer.address()}`, resp); | ||
tcpServer.close(); | ||
unixServer.close(); | ||
if (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.
All the tests pass a callback function. Why do we need this check?
lib/_tls_wrap.js
Outdated
lookup: options.lookup | ||
}; | ||
} | ||
const connect_opt = { |
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 know that this uses the same variable name as the old one, but most part of the core uses camel case. Could you change this?
lib/_tls_wrap.js
Outdated
}; | ||
} | ||
const connect_opt = { | ||
path: options.path, |
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 would prefer a documentation change, which explicitly states that if path
is present, that gets first preference.
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.
That's already stated in the tls
doc. I'll add it to net
.
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 @thefourtheye nits addressed
Ping @bengl |
Whoops! Got swamped with product work and let this slide. I'll try and clean this up in the next few days. |
Makes tls.connect() behave as documented, preferring options.path over options.port. This makes it consistent with net.connect(), so the included test demonstrates that both behave in this way. Also, for consistency, noting the precedence of options.path in net doc.
bbc9851
to
27cf4d2
Compare
@thefourtheye latest commit addresses most of your nits I think, PTAL. Also note the doc change, as requested. New CI: https://ci.nodejs.org/job/node-test-pull-request/10152/ |
On further thought, I agree with @BridgeAR here, in that this is semver-patch, since it's making the behavior match the existing documentation, while it didn't before. I'll remove the |
@nodejs/tsc is everyone fine with this being a semver-patch? |
If there are no objections from tsc by friday it should be ok to proceed with semver-patch |
OK, cool. It's Friday. I'll land this shortly. |
Makes tls.connect() behave as documented, preferring options.path over options.port. This makes it consistent with net.connect(), so the included test demonstrates that both behave in this way. Also, for consistency, noting the precedence of options.path in net doc. PR-URL: #14564 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Landed in 6f1caad. |
Makes tls.connect() behave as documented, preferring options.path over options.port. This makes it consistent with net.connect(), so the included test demonstrates that both behave in this way. Also, for consistency, noting the precedence of options.path in net doc. PR-URL: nodejs/node#14564 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Makes tls.connect() behave as documented, preferring options.path over options.port. This makes it consistent with net.connect(), so the included test demonstrates that both behave in this way. Also, for consistency, noting the precedence of options.path in net doc. PR-URL: #14564 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This broke MQTT.js mqttjs/MQTT.js#699 and mqttjs/MQTT.js#700. It was indeed semver-major. |
I've opted to not land this on 6.x due to the behavior change. @mcollina lmk if you think this should be backported |
Makes tls.connect() behave as documented, preferring options.path over
options.port. This makes it consistent with net.connect(), so the
included test demonstrates that both behave in this way.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
tls, test