Skip to content

Telegram polling dies permanently on grammY long-poll timeout #7239

@liaosvcaf

Description

@liaosvcaf

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_count grows) 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

  1. Run OpenClaw with Telegram in polling mode
  2. Wait for a long-poll timeout (or simulate one)
  3. Observe the log: channel exited: Request to 'getUpdates' timed out after 500 seconds
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions