Skip to content

Commit 53ac130

Browse files
committed
Ensure the server shuts down even if shutdown handlers fail
Previously, synchronous errors in shutdown handlers would fire a promise rejection but skip the process.exit call, which meant we could fail to actually exit. We now forcibly exit in all cases.
1 parent ab27e43 commit 53ac130

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/shutdown.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ async function shutdown() {
1616
console.log('Shutting down...');
1717

1818
await Promise.all(shutdownHandlers.map(
19-
(handler) => handler().catch(reportError)
19+
async (handler) => {
20+
try {
21+
handler();
22+
} catch (e) {
23+
reportError(e);
24+
}
25+
}
2026
));
2127

2228
process.exit(0);

0 commit comments

Comments
 (0)