DB Connection Lifecycle (Open/Close, Pool Hygiene)
On this page
Lifecycle Management
Database connections must be released back to the pool after use. Leaked connections exhaust resources.
Graceful Shutdown
process.on('SIGTERM', async () => {
await pool.end();
process.exit(0);
});
Production Insight
Always close connections during shutdown to avoid orphaned sessions.