From e85bd1e944162f40916c2ad8ef6d8a81e8d9b200 Mon Sep 17 00:00:00 2001 From: Mehdy Dara Date: Mon, 11 Dec 2023 09:16:43 +0100 Subject: [PATCH 1/2] doc: fix agent default value for `keepAlive` Since node 19, option keepAlive is true by default. --- doc/api/http.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/http.md b/doc/api/http.md index e0b2c55a56a3d0..b6f770285e6058 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -142,7 +142,7 @@ changes: header is always sent when using an agent except when the `Connection` header is explicitly specified or when the `keepAlive` and `maxSockets` options are respectively set to `false` and `Infinity`, in which case - `Connection: close` will be used. **Default:** `false`. + `Connection: close` will be used. **Default:** `true`. * `keepAliveMsecs` {number} When using the `keepAlive` option, specifies the [initial delay][] for TCP Keep-Alive packets. Ignored when the From 493d980e8afd816e5d6bab0616f5a29e25ea093c Mon Sep 17 00:00:00 2001 From: Mehdy Dara Date: Thu, 14 Dec 2023 16:01:54 +0100 Subject: [PATCH 2/2] http: use Keep-Alive by default in constructor agents (like global agents) --- lib/_http_agent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_http_agent.js b/lib/_http_agent.js index a4829526f6e138..5327b2aec48f2d 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -108,7 +108,7 @@ function Agent(options) { this.sockets = { __proto__: null }; this.freeSockets = { __proto__: null }; this.keepAliveMsecs = this.options.keepAliveMsecs || 1000; - this.keepAlive = this.options.keepAlive || false; + this.keepAlive = this.options.keepAlive || true; this.maxSockets = this.options.maxSockets || Agent.defaultMaxSockets; this.maxFreeSockets = this.options.maxFreeSockets || 256; this.scheduling = this.options.scheduling || 'lifo';