openclaw - 💡(How to fix) Fix Telegram: Bot not initialized — update spool blocks all message processing

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Telegram polling fails with: Bot not initialized! Either call await bot.init(), or directly set the botInfo option in the Bot constructor. Once this error occurs, ALL subsequent spooled updates stop being processed, effectively blocking all Telegram inbound messages until the gateway is restarted.

Error Message

Full logs available from openclaw logs filtered to channels/telegram. The error repeats every ~500ms for the same update ID until gateway restart.

Root Cause

Location: dist/monitor-polling.runtime-B2bOQy7s.js#drainSpooledUpdates method

async #drainSpooledUpdates(params) {
  for (const update of updates) {
    try {
      await params.bot.handleUpdate(update.update);
      await deleteTelegramSpooledUpdate(update);
    } catch (err) {
      this.opts.log(`[telegram][diag] spooled update ${update.updateId} handler failed; keeping for retry: ${formatErrorMessage(err)}`);
      break;  // ← BUG: stops processing ALL remaining updates
    }
  }
}

Two issues:

  1. Race condition: The bot is being used before grammY's bot.init() completes. The botInfo obtained from the startup getMe probe is passed to createTelegramBot() but grammY still throws Bot not initialized on handleUpdate() — suggesting grammY requires init() to be called even when botInfo is provided at construction time.
  2. Spool DoS: When handleUpdate throws, the break statement stops processing the entire remaining spool. The stuck update is never deleted, so it blocks all subsequent messages indefinitely.

Fix Action

Workaround

Restarting the gateway clears the spool and rebuilds the bot, temporarily resolving the issue. A restart script/automation would mitigate the impact.

Code Example

2026-05-20T22:04:19.225Z error channels/telegram [telegram][diag] spooled update 352733364 handler failed; keeping for retry: Bot not initialized! Either call await bot.init(), or directly set the botInfo option in the Bot constructor to specify a known bot info object.

---

async #drainSpooledUpdates(params) {
  for (const update of updates) {
    try {
      await params.bot.handleUpdate(update.update);
      await deleteTelegramSpooledUpdate(update);
    } catch (err) {
      this.opts.log(`[telegram][diag] spooled update ${update.updateId} handler failed; keeping for retry: ${formatErrorMessage(err)}`);
      break;  // ← BUG: stops processing ALL remaining updates
    }
  }
}
RAW_BUFFERClick to expand / collapse

Description

Telegram polling fails with: Bot not initialized! Either call await bot.init(), or directly set the botInfo option in the Bot constructor. Once this error occurs, ALL subsequent spooled updates stop being processed, effectively blocking all Telegram inbound messages until the gateway is restarted.

Environment

  • OpenClaw: 2026.5.12 (f066dd2)
  • Node.js: v25.8.0
  • macOS (Darwin 25.3.0 arm64)
  • Telegram plugin: isolated ingress polling (worker thread + spooler architecture)

Steps to Reproduce

  1. Configure Telegram channel with isolated ingress polling (default)
  2. Leave gateway running for some time (trigger unclear; appears after gateway restart or polling cycle reset)
  3. A message arrives that causes grammY's handleUpdate to throw before bot.init() completes
  4. Error: spooled update N handler failed; keeping for retry: Bot not initialized!
  5. The drain loop in #drainSpooledUpdates breaks on error, leaving that update in the spool
  6. All subsequent updates queue up behind the stuck update and never process
  7. Telegram appears dead — no replies, no acknowledgment

Actual Behavior

Log snippet showing the error loop:

2026-05-20T22:04:19.225Z error channels/telegram [telegram][diag] spooled update 352733364 handler failed; keeping for retry: Bot not initialized! Either call await bot.init(), or directly set the botInfo option in the Bot constructor to specify a known bot info object.

The same update ID is retried ~every 500ms with the same error. No other updates in the spool are processed.

Expected Behavior

  1. grammY bot should not throw Bot not initialized when botInfo was passed to the constructor
  2. If handleUpdate throws, the drain loop should either: (a) skip the failing update and continue, or (b) delete the failing update from the spool so subsequent updates can be processed
  3. The error should not cause complete message loss on the Telegram channel

Root Cause Analysis

Location: dist/monitor-polling.runtime-B2bOQy7s.js#drainSpooledUpdates method

async #drainSpooledUpdates(params) {
  for (const update of updates) {
    try {
      await params.bot.handleUpdate(update.update);
      await deleteTelegramSpooledUpdate(update);
    } catch (err) {
      this.opts.log(`[telegram][diag] spooled update ${update.updateId} handler failed; keeping for retry: ${formatErrorMessage(err)}`);
      break;  // ← BUG: stops processing ALL remaining updates
    }
  }
}

Two issues:

  1. Race condition: The bot is being used before grammY's bot.init() completes. The botInfo obtained from the startup getMe probe is passed to createTelegramBot() but grammY still throws Bot not initialized on handleUpdate() — suggesting grammY requires init() to be called even when botInfo is provided at construction time.
  2. Spool DoS: When handleUpdate throws, the break statement stops processing the entire remaining spool. The stuck update is never deleted, so it blocks all subsequent messages indefinitely.

Workaround

Restarting the gateway clears the spool and rebuilds the bot, temporarily resolving the issue. A restart script/automation would mitigate the impact.

Suggested Fix (for reference)

In #drainSpooledUpdates:

  • On Bot not initialized error specifically: re-raise to trigger bot re-initialization in the polling cycle, OR
  • On any handleUpdate error: delete the failing update and log a warning, then continue processing the remaining spool instead of breaking

Alternatively, ensure bot.init() is awaited before the first handleUpdate call in the ingress cycle.

Logs

Full logs available from openclaw logs filtered to channels/telegram. The error repeats every ~500ms for the same update ID until gateway restart.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Telegram: Bot not initialized — update spool blocks all message processing