Skip to content

Commit 4fcf476

Browse files
LinkgoronH4ad
authored andcommitted
https: fix connection checking interval not clearing on server close
The connection interval should close when httpsServer.close is called similarly to how it gets cleared when httpServer.close is called. fixes: #48373
1 parent a0e60c1 commit 4fcf476

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

lib/_http_server.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,11 @@ function setupConnectionsTracking(server) {
503503
setInterval(checkConnections.bind(server), server.connectionsCheckingInterval).unref();
504504
}
505505

506+
function httpServerPreClose(server) {
507+
server.closeIdleConnections();
508+
clearInterval(server[kConnectionsCheckingInterval]);
509+
}
510+
506511
function Server(options, requestListener) {
507512
if (!(this instanceof Server)) return new Server(options, requestListener);
508513

@@ -544,7 +549,7 @@ ObjectSetPrototypeOf(Server.prototype, net.Server.prototype);
544549
ObjectSetPrototypeOf(Server, net.Server);
545550

546551
Server.prototype.close = function() {
547-
clearInterval(this[kConnectionsCheckingInterval]);
552+
httpServerPreClose(this);
548553
ReflectApply(net.Server.prototype.close, this, arguments);
549554
};
550555

@@ -1179,4 +1184,5 @@ module.exports = {
11791184
storeHTTPOptions,
11801185
_connectionListener: connectionListener,
11811186
kServerResponse,
1187+
httpServerPreClose,
11821188
};

lib/https.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const {
3131
JSONStringify,
3232
ObjectAssign,
3333
ObjectSetPrototypeOf,
34+
ReflectApply,
3435
ReflectConstruct,
3536
} = primordials;
3637

@@ -43,6 +44,7 @@ assertCrypto();
4344
const tls = require('tls');
4445
const { Agent: HttpAgent } = require('_http_agent');
4546
const {
47+
httpServerPreClose,
4648
Server: HttpServer,
4749
setupConnectionsTracking,
4850
storeHTTPOptions,
@@ -97,6 +99,11 @@ Server.prototype.closeIdleConnections = HttpServer.prototype.closeIdleConnection
9799

98100
Server.prototype.setTimeout = HttpServer.prototype.setTimeout;
99101

102+
Server.prototype.close = function() {
103+
httpServerPreClose(this);
104+
ReflectApply(tls.Server.prototype.close, this, arguments);
105+
};
106+
100107
/**
101108
* Creates a new `https.Server` instance.
102109
* @param {{

0 commit comments

Comments
 (0)