From 2fe94d46f9ee830e09486b059fa9fa72c4963393 Mon Sep 17 00:00:00 2001 From: Stefan Guggisberg Date: Fri, 7 Jun 2024 08:35:18 +0200 Subject: [PATCH] fix: revert PR #476 due to potential regression (#477) --- src/core/h1.js | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/core/h1.js b/src/core/h1.js index 348e011..30d97ff 100644 --- a/src/core/h1.js +++ b/src/core/h1.js @@ -36,20 +36,7 @@ const getAgent = (ctx, protocol) => { return h1.httpsAgent; } // use default (global) agent - /* c8 ignore next 13 */ - /* => code coverage depends on the node version */ - if (https.globalAgent.keepAlive) /* node >= 19 */ { - // As of Node.js v19 the global agent has keep-alive enabled by default: - // https://nodejs.org/api/http.html#class-httpagent - // https://github.com/nodejs/node/issues/37184 - // https://github.com/nodejs/node/pull/43522/files#diff-494d2deee304c672124ecd82d090283595fd3d8c5a80a1825d972a2d229e4944L334-R334 - // In order to guarantee consistent behavior across node versions we - // always create a new agent with keep-alive enabled on Node.js v19+. - h1.httpsAgent = new https.Agent({ keepAlive: false }); - return h1.httpsAgent; - } else /* node <= 18 */ { - return undefined; - } + return undefined; } else { // plain http if (h1.httpAgent) { @@ -60,20 +47,7 @@ const getAgent = (ctx, protocol) => { return h1.httpAgent; } // use default (global) agent - /* c8 ignore next 13 */ - /* => code coverage depends on the node version */ - if (https.globalAgent.keepAlive) /* node >= 19 */ { - // As of Node.js v19 the global agent has keep-alive enabled by default: - // https://nodejs.org/api/http.html#class-httpagent - // https://github.com/nodejs/node/issues/37184 - // https://github.com/nodejs/node/pull/43522/files#diff-494d2deee304c672124ecd82d090283595fd3d8c5a80a1825d972a2d229e4944L334-R334 - // In order to guarantee consistent behavior across node versions we - // always create a new agent with keep-alive enabled on Node.js v19+. - h1.httpAgent = new http.Agent({ keepAlive: false }); - return h1.httpAgent; - } else /* node <= 18 */ { - return undefined; - } + return undefined; } };