Problem
handleAppTermination in src/index.ts is a sync function that fires Deno.exit(0) before Mongo disconnect and Redis quit complete, so the shutdown log is misleading and connections may not close cleanly.
Cite
src/index.ts:56-67:
function handleAppTermination(signal: string) {
log.info(`[${signal}] Signal received: closing MongoDB connection`);
disconnectMongoDB(); // async, returns Promise, not awaited
try {
redisClient.quit(); // ioredis quit() returns Promise, not awaited
} catch { }
log.info("[MongoDB] Connection closed due to app termination");
Deno.exit(0); // fires before either finishes
}
src/configs/database.ts:15 declares export const disconnectMongoDB = async () => { await mongoose.disconnect(); ... }.
Expected
Process awaits both disconnects before exit, matching src/worker.ts:44-52 gracefulShutdown which correctly does await worker.close() + await redisClient.quit().
Actual
On SIGTERM, Deno.exit(0) runs synchronously; unawaited Promises are dropped mid-flight. "Connection closed" log prints before disconnect actually happens.
Env
Repo master @ 2026-04-13, deno.json version 2.0.0-alpha.4, mongoose ^8.8.1, ioredis ^5.4.1, Deno 2.
Thanks for maintaining wei/pull!
Problem
handleAppTerminationinsrc/index.tsis a sync function that firesDeno.exit(0)before Mongo disconnect and Redis quit complete, so the shutdown log is misleading and connections may not close cleanly.Cite
src/index.ts:56-67:src/configs/database.ts:15declaresexport const disconnectMongoDB = async () => { await mongoose.disconnect(); ... }.Expected
Process awaits both disconnects before exit, matching
src/worker.ts:44-52gracefulShutdownwhich correctly doesawait worker.close()+await redisClient.quit().Actual
On SIGTERM,
Deno.exit(0)runs synchronously; unawaited Promises are dropped mid-flight. "Connection closed" log prints before disconnect actually happens.Env
Repo
master@ 2026-04-13,deno.jsonversion2.0.0-alpha.4,mongoose ^8.8.1,ioredis ^5.4.1, Deno 2.Thanks for maintaining wei/pull!