From 7168c73ad131e83e2b10231fb36a5b25efe15592 Mon Sep 17 00:00:00 2001 From: Nitzan Uziely Date: Thu, 8 Jun 2023 13:05:06 +0300 Subject: [PATCH] fixup! https: fix connection checking interval not clearing on server close --- 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, 38 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-http-server-close-destroy-timeout.js create mode 100644 test/parallel/test-https-server-close-destroy-timeout.js diff --git a/lib/_http_server.js b/lib/_http_server.js index 31fc5ba9f82494..6425462c952a3a 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -1185,4 +1185,5 @@ module.exports = { _connectionListener: connectionListener, kServerResponse, httpServerPreClose, + kConnectionsCheckingInterval, }; diff --git a/test/parallel/test-http-server-close-destroy-timeout.js b/test/parallel/test-http-server-close-destroy-timeout.js new file mode 100644 index 00000000000000..b1138ee36d5a90 --- /dev/null +++ b/test/parallel/test-http-server-close-destroy-timeout.js @@ -0,0 +1,13 @@ +'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 361ccf990fabcc..36e9752d36b528 100644 --- a/test/parallel/test-http-server-close-idle.js +++ b/test/parallel/test-http-server-close-idle.js @@ -42,7 +42,6 @@ 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 new file mode 100644 index 00000000000000..e876721f610964 --- /dev/null +++ b/test/parallel/test-https-server-close-destroy-timeout.js @@ -0,0 +1,24 @@ +'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 7f093c47cd8609..49b525dd05f117 100644 --- a/test/parallel/test-https-server-close-idle.js +++ b/test/parallel/test-https-server-close-idle.js @@ -52,7 +52,6 @@ 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