Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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

Backport-PR-URL: #50194
  • Loading branch information
Linkgoron authored and H4ad committed Oct 16, 2023
commit 4ad67a30332676320299ed3b1518227709632003
8 changes: 7 additions & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ function setupConnectionsTracking(server) {
setInterval(checkConnections.bind(server), server.connectionsCheckingInterval).unref();
}

function httpServerPreClose(server) {
server.closeIdleConnections();
clearInterval(server[kConnectionsCheckingInterval]);
}

function Server(options, requestListener) {
if (!(this instanceof Server)) return new Server(options, requestListener);

Expand Down Expand Up @@ -544,7 +549,7 @@ ObjectSetPrototypeOf(Server.prototype, net.Server.prototype);
ObjectSetPrototypeOf(Server, net.Server);

Server.prototype.close = function() {
clearInterval(this[kConnectionsCheckingInterval]);
httpServerPreClose(this);
ReflectApply(net.Server.prototype.close, this, arguments);
};

Expand Down Expand Up @@ -1179,4 +1184,5 @@ module.exports = {
storeHTTPOptions,
_connectionListener: connectionListener,
kServerResponse,
httpServerPreClose,
};
7 changes: 7 additions & 0 deletions lib/https.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const {
JSONStringify,
ObjectAssign,
ObjectSetPrototypeOf,
ReflectApply,
ReflectConstruct,
} = primordials;

Expand All @@ -43,6 +44,7 @@ assertCrypto();
const tls = require('tls');
const { Agent: HttpAgent } = require('_http_agent');
const {
httpServerPreClose,
Server: HttpServer,
setupConnectionsTracking,
storeHTTPOptions,
Expand Down Expand Up @@ -97,6 +99,11 @@ Server.prototype.closeIdleConnections = HttpServer.prototype.closeIdleConnection

Server.prototype.setTimeout = HttpServer.prototype.setTimeout;

Server.prototype.close = function() {
httpServerPreClose(this);
ReflectApply(tls.Server.prototype.close, this, arguments);
};

/**
* Creates a new `https.Server` instance.
* @param {{
Expand Down