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:
parent
dc60cb754d
commit
483f4a2f59
1 changed files with 5 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue