Fix unhandled promise rejections in LoggingService and WebSocketService - prevent crashes from async operations in constructors
This commit is contained in:
@@ -90,7 +90,9 @@ export class LoggingService {
|
|||||||
secretKey: process.env.MINIO_SECRET_KEY
|
secretKey: process.env.MINIO_SECRET_KEY
|
||||||
});
|
});
|
||||||
|
|
||||||
this.ensureBucketExists();
|
this.ensureBucketExists().catch(error => {
|
||||||
|
console.warn('MinIO bucket initialization failed:', error.message);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
console.warn('Minio configuration not found. Logs will only be stored locally and in console.');
|
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!'
|
secretKey: process.env.MINIO_SECRET_KEY || 'serpentrace123!'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.ensureBucketExists();
|
this.ensureBucketExists().catch(error => {
|
||||||
|
console.warn('MinIO bucket initialization failed:', error.message);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('Development mode: MinIO disabled. Set ENABLE_MINIO=true to enable MinIO logging.');
|
console.log('Development mode: MinIO disabled. Set ENABLE_MINIO=true to enable MinIO logging.');
|
||||||
this.minioClient = null;
|
this.minioClient = null;
|
||||||
|
|||||||
@@ -110,8 +110,10 @@ export class WebSocketService {
|
|||||||
this.maxMessagesPerUser = parseInt(process.env.CHAT_MAX_MESSAGES_PER_USER || '100');
|
this.maxMessagesPerUser = parseInt(process.env.CHAT_MAX_MESSAGES_PER_USER || '100');
|
||||||
this.messageCleanupWeeks = parseInt(process.env.CHAT_MESSAGE_CLEANUP_WEEKS || '4');
|
this.messageCleanupWeeks = parseInt(process.env.CHAT_MESSAGE_CLEANUP_WEEKS || '4');
|
||||||
|
|
||||||
// Initialize Redis connection
|
// Initialize Redis connection (handle async without await in constructor)
|
||||||
this.initializeRedis();
|
this.initializeRedis().catch(error => {
|
||||||
|
logError('Redis initialization failed in WebSocketService constructor', error as Error);
|
||||||
|
});
|
||||||
|
|
||||||
this.setupSocketHandlers();
|
this.setupSocketHandlers();
|
||||||
this.setupArchivingScheduler();
|
this.setupArchivingScheduler();
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user