In server.js, runtime errors trigger process.exit(1) immediately, bypassing gracefulShutdown(). This can leave DB/Redis connections open.
Code Reference:
server.js lines 8-17:
process.on('unhandledRejection', ...);
process.on('uncaughtException', ...);
Both call process.exit(1) directly without leaving any room for graceful shutdown.
Expected Behaviour:
Runtime errors should trigger gracefulShutdown() to cleanly close the HTTP server, MongoDB and Redis connections before exiting.
Suggested Fix:
Wrap both error handlers to await gracefulShutdown() before termination:
process.on('unhandledRejection', async (...) => {
logger.error(...);
await gracefulShutdown();
});
process.on('uncaughtException', async (...) => {
logger.error(...);
await gracefulShutdown();
});
File Affected: server.js
In
server.js, runtime errors triggerprocess.exit(1)immediately, bypassinggracefulShutdown(). This can leave DB/Redis connections open.Code Reference:
server.jslines 8-17:Expected Behaviour:
Runtime errors should trigger
gracefulShutdown()to cleanly close the HTTP server, MongoDB and Redis connections before exiting.Suggested Fix:
Wrap both error handlers to
await gracefulShutdown()before termination:File Affected:
server.js