fix: prevent hourly API crash from unhandled CostAggregationService rejection
All checks were successful
Deploy API Server / build-and-unit (push) Successful in 32s
Deploy API Server / current-integration (push) Successful in 30s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Successful in 58s

- setInterval callback lacked .catch() — unhandled Promise rejection
  crashed the Node.js process exactly 1 hour after startup
- AiUsageLog table missing in current DB → aggregateToday() rejects →
  process.exit(1) in Node 22

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
wangdl 2026-06-20 16:25:16 +08:00
parent 703703bb56
commit 36903e797e

View File

@ -16,7 +16,7 @@ export class CostAggregationService implements OnModuleInit, OnModuleDestroy {
} catch (err: any) {
this.logger.warn(`Initial cost aggregation failed: ${err.message}`);
}
this.timer = setInterval(() => this.aggregateToday(), AGGREGATE_INTERVAL_MS);
this.timer = setInterval(() => this.aggregateToday().catch(err => this.logger.warn(`Hourly cost aggregation failed: ${err.message}`)), AGGREGATE_INTERVAL_MS);
}
onModuleDestroy() {