Fix unhandled promise rejections in LoggingService and WebSocketService - prevent crashes from async operations in constructors

This commit is contained in:
magdo
2025-11-25 22:25:09 +01:00
parent 4a5486caa4
commit 8c27b5ea2f
3 changed files with 10 additions and 4 deletions
@@ -110,8 +110,10 @@ export class WebSocketService {
this.maxMessagesPerUser = parseInt(process.env.CHAT_MAX_MESSAGES_PER_USER || '100');
this.messageCleanupWeeks = parseInt(process.env.CHAT_MESSAGE_CLEANUP_WEEKS || '4');
// Initialize Redis connection
this.initializeRedis();
// Initialize Redis connection (handle async without await in constructor)
this.initializeRedis().catch(error => {
logError('Redis initialization failed in WebSocketService constructor', error as Error);
});
this.setupSocketHandlers();
this.setupArchivingScheduler();