Skip to content

Commit

Permalink
Ref: shortening.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Sep 17, 2024
1 parent 22e52bd commit 4ec6bb3
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/graceful-shutdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ export const graceful = ({
server.on("connection", onConnection);
server.on("secureConnection", onConnection);

/**
* Evaluate whether additional steps are required to destroy the socket.
* @see https://github.com/nodejs/node/blob/57bd715d527aba8dae56b975056961b0e429e91e/lib/_http_client.js#L363-L413
*/
const destroySocket = (socket: Duplex) =>
void sockets.delete(socket.destroy());

Expand All @@ -57,12 +53,8 @@ export const graceful = ({
destroySocket(socket);
}
}
// Wait for all in-flight connections to drain, forcefully terminating any
// open connections after the given timeout
for await (const started of setInterval(10, Date.now())) {
if (sockets.size === 0 || Date.now() - started >= timeout) {
break;
}
if (sockets.size === 0 || Date.now() - started >= timeout) break;
}
for (const socket of sockets) destroySocket(socket);
})
Expand Down

0 comments on commit 4ec6bb3

Please sign in to comment.