-
-
Notifications
You must be signed in to change notification settings - Fork 53.1k
Description
Bug
The Telegram polling loop in monitorTelegramProvider crashes permanently when grammY's getUpdates long-poll times out, killing the Telegram channel with no auto-restart. The bot appears online but stops receiving all messages.
Root Cause
grammY throws errors with the message:
Request to 'getUpdates' timed out after 500 seconds
The recovery logic in monitor.ts delegates to isRecoverableTelegramNetworkError() which checks RECOVERABLE_MESSAGE_SNIPPETS for substring matches. The list includes "timeout" (one word), but the actual error message contains "timed out" (two words). Since "timed out".includes("timeout") is false, the error is not classified as recoverable, causing the polling while loop to throw and exit permanently.
Impact
- Severity: High. The Telegram channel silently dies. No error is surfaced to the user. Messages queue up in Telegram's servers (
pending_update_countgrows) but are never consumed. - Recovery: Only a full gateway restart brings Telegram back.
- Trigger: Standard grammY long-poll timeout (500s). Can happen on any transient network hiccup or when Telegram's API is slow to respond.
Reproduction
- Run OpenClaw with Telegram in polling mode
- Wait for a long-poll timeout (or simulate one)
- Observe the log:
channel exited: Request to 'getUpdates' timed out after 500 seconds - Telegram stops receiving messages permanently
Expected Behavior
The polling loop should catch "timed out" errors and retry with exponential backoff, same as other transient network errors.
Fix
Add "timed out" to RECOVERABLE_MESSAGE_SNIPPETS in src/telegram/network-errors.ts.
PR incoming.