Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

bengl
Copy link
Member

@bengl bengl commented Aug 1, 2017

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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

tls, test

@nodejs-github-bot nodejs-github-bot added the tls Issues and PRs related to the tls subsystem. label Aug 1, 2017
@bengl
Copy link
Member Author

bengl commented Aug 1, 2017

@mscdex
Copy link
Contributor

mscdex commented Aug 1, 2017

Is this semver-major?

@bengl
Copy link
Member Author

bengl commented Aug 1, 2017

Yes most likely semver major.

@bengl bengl added the semver-major PRs that contain breaking changes and should be released in the next major version. label Aug 1, 2017
Copy link
Member

@jasnell jasnell left a 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.

@jasnell
Copy link
Member

jasnell commented Aug 8, 2017

ping @nodejs/ctc

@jasnell jasnell requested a review from a team August 8, 2017 23:28
@BridgeAR
Copy link
Member

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,
Copy link
Contributor

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()));
Copy link
Contributor

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));
Copy link
Contributor

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) => {
Copy link
Contributor

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?

Copy link
Member Author

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) {
Copy link
Contributor

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 = {
Copy link
Contributor

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,
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member

@mcollina mcollina left a 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

@BridgeAR
Copy link
Member

Ping @bengl

@bengl
Copy link
Member Author

bengl commented Sep 14, 2017

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.
@bengl
Copy link
Member Author

bengl commented Sep 20, 2017

@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/

@bengl
Copy link
Member Author

bengl commented Sep 20, 2017

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 semver-major label.

@bengl bengl removed the semver-major PRs that contain breaking changes and should be released in the next major version. label Sep 20, 2017
@BridgeAR
Copy link
Member

@nodejs/tsc is everyone fine with this being a semver-patch?

@jasnell
Copy link
Member

jasnell commented Sep 20, 2017

If there are no objections from tsc by friday it should be ok to proceed with semver-patch

@bengl
Copy link
Member Author

bengl commented Sep 22, 2017

OK, cool. It's Friday. I'll land this shortly.

bengl added a commit that referenced this pull request Sep 22, 2017
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]>
@bengl
Copy link
Member Author

bengl commented Sep 22, 2017

Landed in 6f1caad.

@bengl bengl closed this Sep 22, 2017
addaleax pushed a commit to addaleax/ayo that referenced this pull request Sep 23, 2017
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]>
jasnell pushed a commit that referenced this pull request Sep 25, 2017
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]>
@mcollina
Copy link
Member

This broke MQTT.js mqttjs/MQTT.js#699 and mqttjs/MQTT.js#700. It was indeed semver-major.
I do not think we should revert, as the original behavior was undocumented.

@MylesBorins
Copy link
Contributor

I've opted to not land this on 6.x due to the behavior change.

@mcollina lmk if you think this should be backported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants