diff --git a/lib/http/base.js b/lib/http/base.js index 4e48a9056..b2ba8f8f4 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -99,8 +99,12 @@ HttpClient.prototype.request = function (options) mock); requestOptions.data = requestOptions.body; - requestOptions.httpsAgent = agentAndProxyOptions.agentClass(agentAndProxyOptions.agentOptions); - requestOptions.httpsAgent.keepAlive = agentAndProxyOptions.agentOptions.keepAlive; + if (agentAndProxyOptions.httpsAgent) { + requestOptions.httpsAgent = agentAndProxyOptions.httpsAgent; + } else { + requestOptions.httpsAgent = agentAndProxyOptions.agentClass(agentAndProxyOptions.agentOptions); + requestOptions.httpsAgent.keepAlive = agentAndProxyOptions.agentOptions.keepAlive; + } requestOptions.retryDelay = this.constructExponentialBackoffStrategy(); request = axios.request(requestOptions).then(response => { diff --git a/lib/http/node.js b/lib/http/node.js index 7d196f21e..6ee040cd3 100644 --- a/lib/http/node.js +++ b/lib/http/node.js @@ -41,12 +41,22 @@ function NodeHttpClient(connectionConfig) Util.inherits(NodeHttpClient, Base); +const defaultHttpsAgentOptions = { keepAlive: true }; +const defaultHttpsAgent = HttpsAgent(defaultHttpsAgentOptions); + /** * @inheritDoc */ NodeHttpClient.prototype.getAgentAndProxyOptions = function (url, proxy, mock) { const isHttps = Url.parse(url).protocol === 'https:'; + + if (isHttps && !proxy && !mock) { + return { + httpsAgent: defaultHttpsAgent, + }; + } + let agentClass; let agentOptions = { keepAlive: true }; let options; diff --git a/test/integration/testLargeResultSet.js b/test/integration/testLargeResultSet.js index 9b82518b9..973a1163e 100644 --- a/test/integration/testLargeResultSet.js +++ b/test/integration/testLargeResultSet.js @@ -263,13 +263,13 @@ describe('SNOW-743920: Large result set with ~35 chunks', function () { before(async () => { connection = testUtil.createConnection(); + configureLogger('TRACE'); await testUtil.connectAsync(connection); // setting ROWS_PER_RESULTSET causes invalid, not encoded chunks from GCP // await testUtil.executeCmdAsync(connection, 'alter session set ROWS_PER_RESULTSET = 1000000'); await testUtil.executeCmdAsync(connection, 'alter session set USE_CACHED_RESULT = false;'); await testUtil.executeCmdAsync(connection, createTable); await testUtil.executeCmdAsync(connection, populateData); - configureLogger('TRACE'); }); after(async () => {