Skip to content

Commit

Permalink
fix: revert PR #476 due to potential regression (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-guggisberg authored Jun 7, 2024
1 parent 2b33340 commit 2fe94d4
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions src/core/h1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
};

Expand Down

0 comments on commit 2fe94d4

Please sign in to comment.