Summary
Several services create intervals, timeouts, and track connections but never clean them up on module shutdown.
Findings
Impact
Memory usage grows over time. After extended uptime, services may experience degraded performance or OOM.
Suggested Fix
- Add
OnApplicationShutdown or OnModuleDestroy lifecycle hooks to clear intervals/timeouts.
- Add
handleDisconnect to SocketsGateway.
- Cap recursive setTimeout depth and store reference for cleanup.
Related Issues (Memory Leak Pattern)
Summary
Several services create intervals, timeouts, and track connections but never clean them up on module shutdown.
Findings
setIntervalhealth checks stored in map but noonApplicationShutdownhook to clear them.setTimeoutcallsassignServerrecursively with no max depth or cleanup reference.handleConnectionbut nohandleDisconnect, leaving stale client references.Impact
Memory usage grows over time. After extended uptime, services may experience degraded performance or OOM.
Suggested Fix
OnApplicationShutdownorOnModuleDestroylifecycle hooks to clear intervals/timeouts.handleDisconnectto SocketsGateway.Related Issues (Memory Leak Pattern)