Skip to content

https: add extra options to Agent#getName() - #16402

Closed
princjef wants to merge 1 commit into
nodejs:masterfrom
princjef:https-additional-options
Closed

https: add extra options to Agent#getName()#16402
princjef wants to merge 1 commit into
nodejs:masterfrom
princjef:https-additional-options

Conversation

@princjef

Copy link
Copy Markdown
Contributor

Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request()
to accept the options and generate unique sockets appropriately.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

https

@nodejs-github-botnodejs-github-bot added the https Issues or PRs related to the https subsystem. label Oct 23, 2017
@princjef

Copy link
Copy Markdown
ContributorAuthor

See #16196 for more context/discussion

@addaleaxaddaleax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just skimmed over it but this seems sensible to me. Thanks for the PR!

Comment threadlib/https.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this is kind of starting to look like working with a list of options might be an easier choice…

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. How about something like:

constcomponents=[options.ca,options.cert,options.ciphers,options.key,options.pfx,options.rejectUnauthorized,options.servername!==options.host ? options.servername : undefined,options.secureProtocol,options.crl,options.honorCipherOrder,options.ecdhCurve,options.dhparam,options.secureOptions,options.sessionIdContext];for(constcomponentofcomponents){name+=':';if(component!=null){name+=component;}}// or:// name += components// .map(component => component != null ? `:${component}` : ':')// .join('');

There's a potential slight difference in serialization (nulls wouldn't be added for rejectUnauthorized, honorCipherOrder, or secureOptions any more), but it seems like null would either have no impact or be invalid for all three so it feels alright to me.

Thoughts?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it seems like null would either have no impact or be invalid for all three so it feels alright to me.

I agree.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@addaleaxaddaleax added the semver-minor PRs that contain new features and should be released in the next minor version. label Oct 23, 2017
@lpinca

Copy link
Copy Markdown
Member

@princjef
princjefforce-pushed the https-additional-options branch from c881bce to 100d403CompareNovember 4, 2017 21:09
@princjef
princjefforce-pushed the https-additional-options branch from 100d403 to 7c0ba8cCompareNovember 13, 2017 05:19
@princjef

Copy link
Copy Markdown
ContributorAuthor

Updated to integrate the clientCertEngine changes from 6ee985f

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments, otherwise LGTM

Comment threadlib/https.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to be explicit and write component !== null && component !== undefined as that is faster than the implicit way. Using a plain for loop should also be a tad faster than the for of loop.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x != null should in fact be faster than two strict checks but yes, for/of is probably a bit slower than a plain for loop.

What's more, creating a throwaway array like that has a lot of overhead compared to the code it replaces. I expect you'll see a dip in the benchmarks.

@BridgeARBridgeARNov 23, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x != null was faster with Crankshaft. That is not true anymore since Turbofan.

And yes, the array is indeed quite a overhead. I would also rather prevent that but it makes the code here much more readable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is probably enough of a hot path that performance trumps readability. Unless the benchmarks show otherwise, of course - to measure is to know (which doesn't have quite the same ring to it as "meten is weten" in Dutch, but I digress.)

x != null was faster with Crankshaft. That is not true anymore since Turbofan.

It's a wash with TF (or at least it should be, the CSA code paths are practically identical) but x != null is faster with Ignition because it's just one dispatch from the interpreter loop instead of two (or three, if you include the &&.)

Probably still a wash in the grand scheme of things. If nothing else, x != null is more succinct than the long-hand x !== null && x !== undefined.

@princjefprincjefNov 26, 2017

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like collecting values into a temporary array may not be worth the performance hit, in which case the loop goes away anyway. If I remember correctly, the form with separate ifs doesn't have any x != null checks either (it was added to the loop form to better account for numbers/booleans than a straight truthy/falsy check), so that point becomes moot as well. So, shall I flip it back to separate if checks or keep it as an array @BridgeAR@bnoordhuis?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have anything to add of value but re: the performance discussion, there's one notable case where != null is significantly slower and that's when dealing with Objects (due to the possibility of document.all).

Comment threaddoc/api/https.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entries were originally sorted by alphabet. Any reason why you changed that?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember exactly but I believe it was to align with the list in tls.createSecureContext(). That being said, alphabetic probably makes more sense.

Comment threaddoc/api/https.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to keep this reference. There are other places where the agent is mentioned but not referenced. It would probably be good to make all occurances of the Agent a reference instead of removing this.

@BridgeAR

Copy link
Copy Markdown
Member

@princjef would you be so kind and rebase and address the comment by removing the loop? :-)

@BridgeAR

Copy link
Copy Markdown
Member

Ping @princjef

Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request() to
accept the options and generate unique sockets appropriately.
@princjef
princjefforce-pushed the https-additional-options branch from 7c0ba8c to 44475cbCompareJanuary 31, 2018 04:14
@princjef

Copy link
Copy Markdown
ContributorAuthor

Sorry for the delay @BridgeAR. The loop has been removed, the names in the docs alphabetized and the Agent references added.

Let me know if there's anything I missed

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BridgeAR

Copy link
Copy Markdown
Member

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 7, 2018

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BridgeAR

Copy link
Copy Markdown
Member

Landed in 6007a9c 🎉

BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Feb 10, 2018
Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request() to
accept the options and generate unique sockets appropriately.
PR-URL: nodejs#16402
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request() to
accept the options and generate unique sockets appropriately.
PR-URL: #16402
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request() to
accept the options and generate unique sockets appropriately.
PR-URL: #16402
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request() to
accept the options and generate unique sockets appropriately.
PR-URL: #16402
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorinsMylesBorins mentioned this pull request Feb 21, 2018
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request() to
accept the options and generate unique sockets appropriately.
PR-URL: #16402
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins added a commit that referenced this pull request Feb 21, 2018
Notable changes:
* async_hooks:
- deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
#18513
- rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
(Ali Ijaz Sheikh) #18633
* deps:
- update node-inspect to 1.11.3 (Jan Krems)
#18354
- ICU 60.2 bump (Steven R. Loomis)
#17687
- Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
#16889
* http:
- add options to http.createServer() for `IncomingMessage` and
`ServerReponse` (Peter Marton)
#15752
* http2:
- add http fallback options to .createServer (Peter Marton)
#15752
* https:
- Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request()
to accept the options and generate unique sockets appropriately.
(Jeff Principe)
#16402
* inspector:
- --inspect-brk for es modules (Guy Bedford)
#18194
* lib:
- allow process kill by signal number (Sam Roberts)
#16944
* module:
- enable dynamic import (Myles Borins)
#18387
- dynamic import is now supported (Jan Krems)
#15713
* napi:
- add methods to open/close callback scope (Michael Dawson)
#18089
* src:
- allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
#17600
* vm:
- add support for es modules (Gus Caplan)
#17560
PR-URL: #18902
MylesBorins added a commit that referenced this pull request Feb 21, 2018
Notable changes:
* async_hooks:
- deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
#18513
- rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
(Ali Ijaz Sheikh) #18633
* deps:
- update node-inspect to 1.11.3 (Jan Krems)
#18354
- ICU 60.2 bump (Steven R. Loomis)
#17687
- Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
#16889
* http:
- add options to http.createServer() for `IncomingMessage` and
`ServerReponse` (Peter Marton)
#15752
* http2:
- add http fallback options to .createServer (Peter Marton)
#15752
* https:
- Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request()
to accept the options and generate unique sockets appropriately.
(Jeff Principe)
#16402
* inspector:
- --inspect-brk for es modules (Guy Bedford)
#18194
* lib:
- allow process kill by signal number (Sam Roberts)
#16944
* module:
- enable dynamic import (Myles Borins)
#18387
- dynamic import is now supported (Jan Krems)
#15713
* napi:
- add methods to open/close callback scope (Michael Dawson)
#18089
* src:
- allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
#17600
* vm:
- add support for es modules (Gus Caplan)
#17560
PR-URL: #18902
MylesBorins added a commit that referenced this pull request Feb 22, 2018
Notable changes:
* async_hooks:
- deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
#18513
- rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
(Ali Ijaz Sheikh) #18633
* deps:
- update node-inspect to 1.11.3 (Jan Krems)
#18354
- ICU 60.2 bump (Steven R. Loomis)
#17687
- Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
#16889
* http:
- add options to http.createServer() for `IncomingMessage` and
`ServerReponse` (Peter Marton)
#15752
* http2:
- add http fallback options to .createServer (Peter Marton)
#15752
* https:
- Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request()
to accept the options and generate unique sockets appropriately.
(Jeff Principe)
#16402
* inspector:
- --inspect-brk for es modules (Guy Bedford)
#18194
* lib:
- allow process kill by signal number (Sam Roberts)
#16944
* module:
- enable dynamic import (Myles Borins)
#18387
- dynamic import is now supported (Jan Krems)
#15713
* napi:
- add methods to open/close callback scope (Michael Dawson)
#18089
* src:
- allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
#17600
* vm:
- add support for es modules (Gus Caplan)
#17560
PR-URL: #18902
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request() to
accept the options and generate unique sockets appropriately.
PR-URL: nodejs#16402
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Notable changes:
* async_hooks:
- deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh)
nodejs#18513
- rename PromiseWrap.parentId to PromiseWrap.isChainedPromise
(Ali Ijaz Sheikh) nodejs#18633
* deps:
- update node-inspect to 1.11.3 (Jan Krems)
nodejs#18354
- ICU 60.2 bump (Steven R. Loomis)
nodejs#17687
- Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems)
nodejs#16889
* http:
- add options to http.createServer() for `IncomingMessage` and
`ServerReponse` (Peter Marton)
nodejs#15752
* http2:
- add http fallback options to .createServer (Peter Marton)
nodejs#15752
* https:
- Adds the remaining options from tls.createSecureContext() to the
string generated by Agent#getName(). This allows https.request()
to accept the options and generate unique sockets appropriately.
(Jeff Principe)
nodejs#16402
* inspector:
- --inspect-brk for es modules (Guy Bedford)
nodejs#18194
* lib:
- allow process kill by signal number (Sam Roberts)
nodejs#16944
* module:
- enable dynamic import (Myles Borins)
nodejs#18387
- dynamic import is now supported (Jan Krems)
nodejs#15713
* napi:
- add methods to open/close callback scope (Michael Dawson)
nodejs#18089
* src:
- allow --perf-(basic-)?prof in NODE_OPTIONS (Leko)
nodejs#17600
* vm:
- add support for es modules (Gus Caplan)
nodejs#17560
PR-URL: nodejs#18902
@MylesBorins

Copy link
Copy Markdown
Contributor

is this something we would want to backport to v8.x?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.httpsIssues or PRs related to the https subsystem.semver-minorPRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@princjef@lpinca@BridgeAR@MylesBorins@apapirovski@mcollina@bnoordhuis@jasnell@addaleax@nodejs-github-bot