From 0995c9b0e6ad4c9feb459d4e8b76241333a1e919 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 29 Jan 2020 16:56:05 -0800 Subject: [PATCH] Update comment with new information --- packages/grpc-js/src/subchannel.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/grpc-js/src/subchannel.ts b/packages/grpc-js/src/subchannel.ts index 06f26892..bb64bd93 100644 --- a/packages/grpc-js/src/subchannel.ts +++ b/packages/grpc-js/src/subchannel.ts @@ -297,6 +297,9 @@ export class Subchannel { connectionOptions.servername = getDefaultAuthority(this.channelTarget); } } else { + /* In all but the most recent versions of Node, http2.connect does not use + * the options when establishing plaintext connections, so we need to + * establish that connection explicitly. */ connectionOptions.createConnection = (authority, option) => { /* net.NetConnectOpts is declared in a way that is more restrictive * than what net.connect will actually accept, so we use the type @@ -316,7 +319,12 @@ export class Subchannel { * as documented for plaintext connections here: * https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener * and for TLS connections here: - * https://nodejs.org/api/tls.html#tls_tls_connect_options_callback. + * https://nodejs.org/api/tls.html#tls_tls_connect_options_callback. In + * earlier versions of Node, http2.connect passes these options to + * tls.connect but not net.connect, so in the insecure case we still need + * to set the createConnection option above to create the connection + * explicitly. We cannot do that in the TLS case because http2.connect + * passes necessary additional options to tls.connect. * The first argument just needs to be parseable as a URL and the scheme * determines whether the connection will be established over TLS or not. */