← Back to PRs

#14741: feat: telegram resilience utilities

by kalachbeg open 2026-02-12 15:32 View on GitHub →
docs channel: telegram stale size: M
Add health monitoring, retry with backoff, and circuit breaker for telegram integration. Addresses stability issues for channel connections: - Handles transient getUpdates timeouts with exponential backoff - Prevents cascading failures with circuit breaker pattern - Rate limit (429) errors back off naturally, don't trip breaker permanently - Integrates with existing channels.telegram.timeoutSeconds + retry config Components: - BotHealthCheck: periodic health checks with failure callbacks - retryWithBackoff: exponential backoff retry with jitter - Circuit: state machine (closed → open → half-open) with logging Sources: - https://github.com/openclaw/openclaw/issues/4617 - https://github.com/openclaw/openclaw/issues/8140 - https://docs.openclaw.ai/channels/telegram Tested locally with unit tests covering health, retry, and circuit state transitions. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Adds new Telegram resilience primitives: a `Circuit` circuit-breaker state machine (`src/telegram/circuit.ts`), a `BotHealthCheck` periodic health monitor (`src/telegram/health.ts`), and accompanying unit tests (`src/telegram/resilience.test.ts`). Also introduces a docs page describing intended usage (`docs/TELEGRAM_RESILIENCE.md`). The code is largely self-contained under `src/telegram/`, but the docs example currently diverges from the actual TS APIs, and the health-check timeout implementation leaks timers on successful checks. <h3>Confidence Score: 3/5</h3> - Moderately safe to merge after fixing a couple correctness issues in docs and health-check timeout handling. - Core changes are small and localized, but the docs example currently references non-existent options/methods and `BotHealthCheck.check()` leaves a pending timeout on success, which can accumulate timers in long-running processes. - docs/TELEGRAM_RESILIENCE.md, src/telegram/health.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs