fix: add global uncaught exception handlers to capture startup crashes
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 31s

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
WangDL 2026-05-24 12:38:30 +08:00
parent 79018e8d86
commit 80ac9f9834

View File

@ -97,4 +97,19 @@ async function bootstrap() {
await app.listen(port);
console.log(`[API] Server running on http://localhost:${port}`);
}
bootstrap();
// Startup Crash Diagnostics
process.on('uncaughtException', (err) => {
console.error('[FATAL] Uncaught Exception:', err.message);
console.error(err.stack);
process.exit(1);
});
process.on('unhandledRejection', (reason) => {
console.error('[FATAL] Unhandled Rejection:', reason);
process.exit(1);
});
bootstrap().catch((err) => {
console.error('[FATAL] Bootstrap failed:', err.message);
console.error(err.stack);
process.exit(1);
});