File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
506511function Server ( options , requestListener ) {
507512 if ( ! ( this instanceof Server ) ) return new Server ( options , requestListener ) ;
508513
@@ -544,7 +549,7 @@ ObjectSetPrototypeOf(Server.prototype, net.Server.prototype);
544549ObjectSetPrototypeOf ( Server , net . Server ) ;
545550
546551Server . 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} ;
Original file line number Diff line number Diff 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();
4344const tls = require ( 'tls' ) ;
4445const { Agent : HttpAgent } = require ( '_http_agent' ) ;
4546const {
47+ httpServerPreClose,
4648 Server : HttpServer ,
4749 setupConnectionsTracking,
4850 storeHTTPOptions,
@@ -97,6 +99,11 @@ Server.prototype.closeIdleConnections = HttpServer.prototype.closeIdleConnection
9799
98100Server . 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 {{
You can’t perform that action at this time.
0 commit comments