Skip to content

typescript.graceful_shutdown

Stability High

Detects servers without graceful shutdown handling.

Missing graceful shutdown:

  • Request failures — In-flight requests dropped
  • Data loss — Uncommitted transactions lost
  • Connection leaks — Clients left hanging
// ❌ Before (no graceful shutdown)
const server = app.listen(3000);
// ✅ After (with graceful shutdown)
const server = app.listen(3000);
const shutdown = async () => {
console.log('Shutting down gracefully...');
server.close(() => {
console.log('HTTP server closed');
});
// Give time for in-flight requests
await new Promise(resolve => setTimeout(resolve, 5000));
// Close database connections
await db.close();
process.exit(0);
};
process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
  • Missing SIGTERM/SIGINT handlers
  • server.close() not called
  • No connection draining logic

Unfault can add graceful shutdown handlers with proper cleanup.