From bc7c5c5bfe4041b747a74aaac7460d382785e730 Mon Sep 17 00:00:00 2001 From: Kumar Rishav Date: Tue, 2 Apr 2024 22:01:55 +0000 Subject: [PATCH] http: remove closeIdleConnections function while calling server close.\n Correcting the nodejs#50194 backporting mistake.\n closeIdleConnections shouldnot be called while server.close in node v18.\n This behavior is for node v19 and above.\n fixes: nodejs#52330, nodejs#51677 --- lib/_http_server.js | 1 - .../test-http-server-close-destroy-timeout.js | 13 ---------- test/parallel/test-http-server-close-idle.js | 1 + ...test-https-server-close-destroy-timeout.js | 24 ------------------- test/parallel/test-https-server-close-idle.js | 1 + 5 files changed, 2 insertions(+), 38 deletions(-) delete mode 100644 test/parallel/test-http-server-close-destroy-timeout.js delete mode 100644 test/parallel/test-https-server-close-destroy-timeout.js diff --git a/lib/_http_server.js b/lib/_http_server.js index 0dbf11ce079156..1f90b2237f6699 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -506,7 +506,6 @@ function setupConnectionsTracking() { } function httpServerPreClose(server) { - server.closeIdleConnections(); clearInterval(server[kConnectionsCheckingInterval]); } diff --git a/test/parallel/test-http-server-close-destroy-timeout.js b/test/parallel/test-http-server-close-destroy-timeout.js deleted file mode 100644 index b1138ee36d5a90..00000000000000 --- a/test/parallel/test-http-server-close-destroy-timeout.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const { createServer } = require('http'); -const { kConnectionsCheckingInterval } = require('_http_server'); - -const server = createServer(function(req, res) {}); -server.listen(0, common.mustCall(function() { - assert.strictEqual(server[kConnectionsCheckingInterval]._destroyed, false); - server.close(common.mustCall(() => { - assert(server[kConnectionsCheckingInterval]._destroyed); - })); -})); diff --git a/test/parallel/test-http-server-close-idle.js b/test/parallel/test-http-server-close-idle.js index 36e9752d36b528..361ccf990fabcc 100644 --- a/test/parallel/test-http-server-close-idle.js +++ b/test/parallel/test-http-server-close-idle.js @@ -42,6 +42,7 @@ server.listen(0, function() { assert(response.startsWith('HTTP/1.1 200 OK\r\nConnection: keep-alive')); assert.strictEqual(connections, 2); + server.closeIdleConnections(); server.close(common.mustCall()); // Check that only the idle connection got closed diff --git a/test/parallel/test-https-server-close-destroy-timeout.js b/test/parallel/test-https-server-close-destroy-timeout.js deleted file mode 100644 index e876721f610964..00000000000000 --- a/test/parallel/test-https-server-close-destroy-timeout.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -const common = require('../common'); -const assert = require('assert'); -if (!common.hasCrypto) { - common.skip('missing crypto'); -} - -const { createServer } = require('https'); -const { kConnectionsCheckingInterval } = require('_http_server'); - -const fixtures = require('../common/fixtures'); - -const options = { - key: fixtures.readKey('agent1-key.pem'), - cert: fixtures.readKey('agent1-cert.pem') -}; - -const server = createServer(options, function(req, res) {}); -server.listen(0, common.mustCall(function() { - assert.strictEqual(server[kConnectionsCheckingInterval]._destroyed, false); - server.close(common.mustCall(() => { - assert(server[kConnectionsCheckingInterval]._destroyed); - })); -})); diff --git a/test/parallel/test-https-server-close-idle.js b/test/parallel/test-https-server-close-idle.js index 49b525dd05f117..7f093c47cd8609 100644 --- a/test/parallel/test-https-server-close-idle.js +++ b/test/parallel/test-https-server-close-idle.js @@ -52,6 +52,7 @@ server.listen(0, function() { assert(response.startsWith('HTTP/1.1 200 OK\r\nConnection: keep-alive')); assert.strictEqual(connections, 2); + server.closeIdleConnections(); server.close(common.mustCall()); // Check that only the idle connection got closed