Skip to content

Commit 6370778

Browse files
committed
fix(server): add timeout to graceful shutdown
1 parent a7282cf commit 6370778

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

server/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ httpServer.listen(PORT, () => {
7272
const handleShutdown = async (signal: string) => {
7373
console.log(`\n[INFO] Received ${signal}. Initiating graceful shutdown...`);
7474

75+
// Force exit after 10s if graceful shutdown hangs
76+
setTimeout(() => {
77+
console.error('[ERROR] Graceful shutdown timed out. Forcing exit.');
78+
process.exit(1);
79+
}, 10000).unref();
80+
7581
try {
7682
// Stop accepting new connections
7783
httpServer.close();

0 commit comments

Comments
 (0)