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
@@ -90,7 +90,9 @@ export class LoggingService {
secretKey: process.env.MINIO_SECRET_KEY
});
this.ensureBucketExists();
this.ensureBucketExists().catch(error => {
console.warn('MinIO bucket initialization failed:', error.message);
});
} else {
console.warn('Minio configuration not found. Logs will only be stored locally and in console.');
}
@@ -105,7 +107,9 @@ export class LoggingService {
secretKey: process.env.MINIO_SECRET_KEY || 'serpentrace123!'
});
this.ensureBucketExists();
this.ensureBucketExists().catch(error => {
console.warn('MinIO bucket initialization failed:', error.message);
});
} else {
console.log('Development mode: MinIO disabled. Set ENABLE_MINIO=true to enable MinIO logging.');
this.minioClient = null;
@@ -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();
Binary file not shown.