Workaround for keepAlive false

This commit is contained in:
delvedor
2019-03-01 09:02:31 +01:00
parent ed3cca0fe6
commit f175f83d34

View File

@ -26,10 +26,13 @@ class Connection {
throw new ConfigurationError(`Invalid protocol: '${this.url.protocol}'`)
}
// Probably there is a bug in Node Core
// see https://github.com/nodejs/node/issues/26357
const keepAliveFalse = opts.agent && opts.agent.keepAlive === false
const agentOptions = Object.assign({}, {
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 256,
maxSockets: keepAliveFalse ? Infinity : 256,
maxFreeSockets: 256
}, opts.agent)
this._agent = this.url.protocol === 'http:'