feat(runtime): stability foundation - global handlers, pino injection, health/metrics#15
Conversation
…tion, health/metrics endpoints - Register unhandledRejection handler with 60s dedup window (threshold 5) - Register uncaughtException handler with controlled shutdown + 10s timeout - Add graceful shutdown timeout (10s) for SIGINT/SIGTERM - Inject pino Logger into TelegramMessageDeps, sweepExpiredConversations - Replace 4 console.error calls in messages.ts, conversation-expiry.ts, updates.ts with structured pino logger calls - Add DeliveryService.stats(), ConversationService.conversationStats() and messageStats(), AiDraftService.stats() - all synchronous GROUP BY queries - Add GET /healthz endpoint (public, returns bot/db/uptime status, 503 if degraded) - Add GET /metrics endpoint (authenticated, returns message/delivery/conversation/ ai_draft counts as JSON) - Extend WebConsoleOptions with dbHealthCheck and collectMetrics callbacks - Add 6 new test cases covering healthz, metrics auth, and stats aggregation Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com>
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (10)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
unhandledRejectionhandler with 60s dedup window (suppresses after 5 repeats)uncaughtExceptionhandler with controlled shutdown + 10s force-exit timeoutLoggerintoTelegramMessageDepsandsweepExpiredConversationsconsole.errorcalls inmessages.ts,conversation-expiry.ts,updates.tswith structured pino logger callsDeliveryService.stats(),ConversationService.conversationStats()+messageStats(),AiDraftService.stats()GET /healthzendpoint (public, returns bot/db/uptime status, 503 if degraded)GET /metricsendpoint (authenticated, returns message/delivery/conversation/ai_draft counts)WebConsoleOptionswithdbHealthCheckandcollectMetricscallbacksProblem
The process had no
unhandledRejection/uncaughtExceptionhandlers, so async errors from timers/workers could silently crash or hang the process. Critical hot paths usedconsole.errorinstead of pino, losing structured logging. Container orchestration had no health check endpoint, and ops had no metrics visibility.Verification
npm run verifypassed (check + 31 tests + audit 0 vulns)