Skip to content

Commit

Permalink
fixup! https: fix connection checking interval not clearing on server…
Browse files Browse the repository at this point in the history
… close
  • Loading branch information
Linkgoron authored and H4ad committed Oct 15, 2023
1 parent 4fcf476 commit 7168c73
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1185,4 +1185,5 @@ module.exports = {
_connectionListener: connectionListener,
kServerResponse,
httpServerPreClose,
kConnectionsCheckingInterval,
};
13 changes: 13 additions & 0 deletions test/parallel/test-http-server-close-destroy-timeout.js
Original file line number Diff line number Diff line change
@@ -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);
}));
}));
1 change: 0 additions & 1 deletion test/parallel/test-http-server-close-idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions test/parallel/test-https-server-close-destroy-timeout.js
Original file line number Diff line number Diff line change
@@ -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);
}));
}));
1 change: 0 additions & 1 deletion test/parallel/test-https-server-close-idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7168c73

Please sign in to comment.