mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-26 12:35:35 +02:00
fix(gateway): graceful degradation when MySQL is unavailable
Instead of throwing and crashing the gateway when MySQL connection fails, close the broken pool and continue with pool=null so the isAvailable() guard handles it gracefully. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -40,7 +40,11 @@ export class DatabaseService implements OnModuleInit, OnModuleDestroy {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
console.log("[DatabaseService] Error:", message);
|
||||
this.logger.error(`Failed to connect to MySQL: ${message}`);
|
||||
throw error;
|
||||
// Graceful degradation: close broken pool, keep this.pool = null
|
||||
if (this.pool) {
|
||||
await this.pool.end().catch(() => {});
|
||||
this.pool = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user