File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,11 @@ class Server extends EventEmitter<Server.Events> {
5858 return this . server . keepAliveTimeout ;
5959 }
6060
61- public async close ( ) : Promise < void > {
61+ /**
62+ * Close the server. Will stop accepting new connections and wait for existing connections to close.
63+ * @param [timeout=5000] Maximum time to wait for existing connections to close before forcibly closing them.
64+ */
65+ public async close ( timeout = 5000 ) : Promise < void > {
6266 this . emit ( "closing" ) ;
6367 await Promise . race ( [
6468 new Promise < void > ( resolve => {
@@ -67,7 +71,7 @@ class Server extends EventEmitter<Server.Events> {
6771 new Promise < void > ( resolve => setTimeout ( ( ) => {
6872 this . server . closeAllConnections ( ) ;
6973 resolve ( ) ;
70- } , 5000 ) ) ,
74+ } , timeout ) ) ,
7175 ] ) ;
7276 this . emit ( "closed" ) ;
7377 }
You can’t perform that action at this time.
0 commit comments