Skip to content

fix: add lifecycle cleanup hooks and error handling for async operations#141

Open
Flegma wants to merge 2 commits intomainfrom
audit/375-lifecycle-cleanup
Open

fix: add lifecycle cleanup hooks and error handling for async operations#141
Flegma wants to merge 2 commits intomainfrom
audit/375-lifecycle-cleanup

Conversation

@Flegma
Copy link
Copy Markdown
Contributor

@Flegma Flegma commented Apr 8, 2026

Summary

  • Add OnApplicationShutdown to RedisManagerService to clear health check intervals and disconnect Redis on shutdown
  • Cap recursive setTimeout retries in MatchAssistantService.assignServer to 10 attempts
  • Replace void fire-and-forget patterns with .catch() error handlers in AppModule, SocketsService, and MatchesModule

Closes 5stackgg/5stack-panel#375, 5stackgg/5stack-panel#376

Test plan

  • Verify Redis health check intervals are cleared on app shutdown
  • Verify assignServer stops retrying after 10 attempts
  • Verify async errors are logged instead of silently dropped

Add OnApplicationShutdown to RedisManagerService to clear health check
intervals and disconnect Redis on shutdown. Cap recursive setTimeout
retries in assignServer to 10. Replace void fire-and-forget patterns
with .catch() error handlers in AppModule, SocketsService, and
MatchesModule.
},
);
)
.catch((err) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id rather error the whole process.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted all .catch() patterns back to void fire-and-forget across matches.module.ts, app.module.ts, and sockets.service.ts — unhandled rejections will now crash the process as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API] Missing NestJS lifecycle cleanup — intervals, recursive timeouts, stale WS refs

2 participants