typescript.graceful_shutdown
Stability
High
Detects servers without graceful shutdown handling.
Why It Matters
Section titled “Why It Matters”Missing graceful shutdown:
- Request failures — In-flight requests dropped
- Data loss — Uncommitted transactions lost
- Connection leaks — Clients left hanging
Example
Section titled “Example”// ❌ 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);What Unfault Detects
Section titled “What Unfault Detects”- Missing SIGTERM/SIGINT handlers
- server.close() not called
- No connection draining logic
Auto-Fix
Section titled “Auto-Fix”Unfault can add graceful shutdown handlers with proper cleanup.