Skip to content

[Bug]: webhookUrl configured but long-polling transport still runs getUpdates, continuously wiping the registered webhook #90254

Closed

Description

@travellingsoldier85

Summary

When channels.telegram.webhookUrl is configured, OpenClaw continues running its long-polling transport in the background. This polling transport periodically calls getUpdates, which causes Telegram to silently delete the registered webhook. The result is a continuous wipe cycle: webhook is set on startup → polling transport issues getUpdates ~30s later → Telegram interprets this as "switch to polling mode" and clears the webhook → inbound messages are lost until the webhook is manually re-registered.

Version

OpenClaw 2026.6.1 (confirmed via openclaw --version)

Steps to reproduce

  1. Configure channels.telegram.webhookUrl + channels.telegram.webhookSecret in openclaw.json
  2. Start or restart the gateway
  3. Observe via getWebhookInfo: webhook URL is set immediately after startup
  4. Wait 20–35 seconds
  5. Observe via getWebhookInfo: webhook URL is now empty — cleared by Telegram
  6. Repeat step 4–5: it wipes every ~30 seconds continuously as long as the gateway runs

Root cause

The long-polling watchdog (pollingStallThresholdMs) runs even when webhookUrl is configured — OpenClaw has no pure-webhook mode. The polling transport calls getUpdates on its liveness cycle; per Telegram Bot API specification, calling getUpdates while a webhook is active automatically deletes the webhook (this is documented Telegram behaviour, not a Telegram bug).

From the OpenClaw docs (channels/telegram.md):

"Long polling is the default mode; webhook mode is optional."
"A still-active webhook surfaces as a getUpdates conflict; OpenClaw then rebuilds the Telegram transport and retries webhook cleanup."

This confirms the polling path always runs. The pollingStallThresholdMs config key (range 30000–600000) only tunes the watchdog timing — it does not disable polling.

The complete channels.telegram schema was enumerated via openclaw config schema lookup channels.telegram. There is no disablePolling, mode: "webhook", webhookOnly, transport, or any flag to stop the poller when in webhook mode.

Impact

  • Inbound Telegram DMs and group messages silently dropped for ~30s windows every minute
  • Every gateway restart resets the webhook → DM blackout until manually re-registered
  • Even with webhookUrl configured, the bot receives no messages unless an external process continuously re-asserts setWebhook

Current workaround

A systemd timer fires every 15s, calls setWebhook via getWebhookInfo check (never getUpdates), and re-asserts the webhook before the next polling wipe. This works but is a band-aid.

# /etc/systemd/system/tg-webhook-guard.timer
[Timer]
OnBootSec=20s
OnUnitActiveSec=15s
AccuracySec=1s

Requested fix

Add a disablePolling: true or transport: "webhook" config flag to channels.telegram that:

  1. Skips starting the long-polling transport entirely when webhookUrl is set
  2. Does NOT call getUpdates or deleteWebhook during normal operation
  3. Only uses the webhook listener path for inbound messages

Alternatively, make webhook mode the automatic behaviour when webhookUrl is configured (breaking change, but semantically correct).

Evidence

Gateway log shows liveness warning: eventLoopDelayP99Ms=4099 alongside continuous polling transport restarts. Empirical test: set webhook, poll getWebhookInfo every 10s with no guard running:

T+0s   → set
T+10s  → https://example.com/telegram-webhook  ✅
T+20s  → https://example.com/telegram-webhook  ✅
T+30s  → (empty)  ❌  ← wiped by getUpdates
T+40s  → (empty)

Reproduced across 3 independent gateway restarts on OpenClaw 2026.6.1.

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 7:34 AM ET / 11:34 UTC.

    Summary
    Keep open: current main and the latest release still call Telegram deleteWebhook from the webhook abort path, while the focused repair is an open, unmerged PR that still needs review/proof before this issue can be closed.

    Reproducibility: yes. source-reproducible: current main still calls deleteWebhook when the webhook abort signal fires, and the reporter supplied repeated getWebhookInfo clearing evidence. I did not run a live Telegram current-main reproduction.

    Root-cause cluster
    Relationship: canonical
    Canonical: #90254
    Summary: This issue is the canonical user report; the linked PR is the current open candidate fix and no merged fix exists on main yet.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    No new repair job: #94506 is open, uses closing syntax, and already owns the focused repair path.

    Review details

    Best possible solution:

    Review and land #94506, or an equivalent focused lifecycle fix, so webhook registration persists across transient restarts while polling-mode cleanup remains intact.

    Do we have a high-confidence way to reproduce the issue?

    Yes, source-reproducible: current main still calls deleteWebhook when the webhook abort signal fires, and the reporter supplied repeated getWebhookInfo clearing evidence. I did not run a live Telegram current-main reproduction.

    Is this the best way to solve the issue?

    Yes for the linked lifecycle direction, not for the original new config flag proposal. Current main already selects webhook mode from webhookUrl; the narrow maintainable fix is to stop transient webhook shutdown from deregistering Telegram while leaving polling-mode cleanup separate.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Live Telegram current-main reproduction was not run in this read-only review; the external cadence rests on reporter diagnostics plus source inspection.
    • The linked PR is still open and its previous review requested live Telegram proof before merge.

    Codex review notes: model internal, reasoning high; reviewed against d1cbe29f3d52.

    Label changes

    Label changes:

    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • remove clawsweeper:needs-live-repro: Current issue advisory state no longer selects this label.
    • remove issue-rating: 🐚 platinum hermit: Current issue advisory state no longer selects this label.

    Label justifications:

    • P2: This is a bounded Telegram channel reliability bug with concrete inbound message-loss impact but limited blast radius.
    • impact:message-loss: Repeated webhook deregistration can prevent Telegram DMs and group messages from reaching OpenClaw.
    Evidence reviewed

    What I checked:

    • Issue discussion and live reporter evidence: The reporter updated the root cause from a polling-config theory to the webhook abort path, and supplied repeated getWebhookInfo observations showing the webhook URL clearing on a regular cadence in OpenClaw 2026.6.1.
    • Current main still clears the webhook on abort: startTelegramWebhook registers a shutdown path that calls bot.api.deleteWebhook({ drop_pending_updates: false }) when the abort signal fires. (extensions/telegram/src/webhook.ts:418, d1cbe29f3d52)
    • Webhook mode is already selected from config: The Telegram channel passes useWebhook: Boolean(account.config.webhookUrl), so the remaining bug is the webhook lifecycle cleanup path rather than a missing transport-mode flag. (extensions/telegram/src/channel.ts:1083, d1cbe29f3d52)
    • Current regression expectation still matches the bug: The current webhook test still expects shutdown to call deleteWebhook, confirming main has not adopted the linked fix behavior. (extensions/telegram/src/webhook.test.ts:1046, d1cbe29f3d52)
    • Telegram Bot API contract checked: The official Telegram Bot API page says getUpdates and webhooks are mutually exclusive, and deleteWebhook removes webhook integration when switching back to getUpdates.
    • Latest release still contains the abort cleanup: Release v2026.6.9 is published, and the tag still contains the same webhook shutdown deleteWebhook call and test expectation. (extensions/telegram/src/webhook.ts:418, c645ec4555c0)

    Likely related people:

    • steipete: Authored the original Telegram grammY webhook support and later restored Telegram webhook-mode health after restarts in the central channel/webhook path. (role: feature history contributor; confidence: high; commits: 4d3d9cca2ab5, 9d7d961db82a; files: src/telegram/webhook.ts, extensions/telegram/src/channel.ts, extensions/telegram/src/webhook.ts)
    • huntharo: Authored substantial webhook hang tests and fixes in the historical shutdown/startup surface. (role: webhook behavior contributor; confidence: medium; commits: ee594e2fdb71; files: src/telegram/webhook.ts, src/telegram/webhook.test.ts)
    • obviyus: Authored recent polling startup cleanup behavior adjacent to the separate polling-mode deleteWebhook path. (role: recent polling and webhook-cleanup contributor; confidence: medium; commits: 5b94c4ce9396; files: extensions/telegram/src/monitor.ts, extensions/telegram/src/polling-session.ts, docs/channels/telegram.md)
    • joshavant: Authored recent polling ingress and event-loop stall work in the Telegram reliability area referenced by the reporter's cadence observations. (role: recent polling ingress contributor; confidence: medium; commits: fd244fd76de3; files: extensions/telegram/src/monitor.ts, extensions/telegram/src/polling-session.ts, extensions/telegram/src/telegram-ingress-worker.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. travellingsoldier85 commented on Jun 4, 2026

    @travellingsoldier85
    Author

    Update — Root Fix Found via Schema Inspection

    After diving deeper into the OpenClaw config schema via openclaw config schema, the real fix was discovered:

    channels.telegram.actions.poll: false

    This is an undocumented schema key (not mentioned in the official docs at https://docs.openclaw.ai/channels/telegram) that disables the polling transport entirely, preventing getUpdates calls that were wiping the webhook.

    Config fix

    {
      "channels": {
        "telegram": {
          "webhookUrl": "https://your-domain.com/telegram-webhook",
          "webhookSecret": "<secret>",
          "actions": {
            "poll": false
          }
        }
      }
    }

    Test result (7/7 consecutive getWebhookInfo checks over 70s, all stable):

    T+10s: ✅ STABLE
    T+20s: ✅ STABLE
    T+30s: ✅ STABLE
    T+40s: ✅ STABLE
    T+50s: ✅ STABLE
    T+60s: ✅ STABLE
    T+70s: ✅ STABLE
    

    After setting actions.poll: false and restarting the gateway, the webhook stays registered permanently without any external guard process.

    Remaining issue

    channels.telegram.actions.poll is not documented in the official Telegram channel docs. The docs only mention webhookUrl, webhookSecret, webhookPath, webhookHost, webhookPort, and webhookCertPath — with no mention of actions.poll as the required companion key to actually disable polling in webhook mode.

    Request: Please add channels.telegram.actions.poll: false to the webhook mode setup instructions in the docs. Without it, any webhookUrl deployment silently continues polling and self-wipes the webhook every ~30 seconds.

  3. travellingsoldier85 commented on Jun 4, 2026

    @travellingsoldier85
    Author

    Deeper Investigation — Real Root Cause

    After further source code analysis of the compiled dist files, the true root cause is more nuanced:

    What channels.telegram.actions.poll: false actually does

    This key controls whether the bot can send Telegram "poll" message types (quizzes/surveys) — not the long-polling transport. It does not disable polling. My earlier comment was incorrect.

    Actual root cause — webhook runtime transport rebuild loop

    From monitor-webhook.runtime-BDuy-hXn.js:

    const shutdown = () => {
        shutDown = true;
        withTelegramApiErrorLogging({
            operation: "deleteWebhook",
            fn: () => bot.api.deleteWebhook({ drop_pending_updates: false })
        }).catch(() => {});
        // ...
    };
    if (opts.abortSignal) opts.abortSignal.addEventListener("abort", shutdown, { once: true });

    The webhook runtime calls deleteWebhook whenever its abortSignal fires. This fires during:

    1. Gateway config hot-reloads (observed: config change detected; evaluating reload (channels.telegram.actions))
    2. Event loop pressure causing the transport liveness probe to time out and trigger a rebuild (eventLoopDelayP99Ms=4099ms observed during heavy work)

    After deleteWebhook, the runtime restarts and calls setWebhook again — but under event loop pressure, the setWebhook call can fail silently, leaving the webhook empty until the next successful retry.

    The fix that actually works

    A systemd timer firing every 15 seconds that re-asserts setWebhook via getWebhookInfo check (never getUpdates):

    # /etc/systemd/system/tg-webhook-guard.timer
    [Timer]
    OnBootSec=20s
    OnUnitActiveSec=15s
    AccuracySec=1s

    This beats both the ~30s transport rebuild cycle and any silent setWebhook failures.

    Requested fix (updated)

    1. The webhook runtime should retry setWebhook with exponential backoff after any deleteWebhook → setWebhook cycle, and log when the re-registration fails
    2. The abortSignal chain should not trigger deleteWebhook during transient liveness probe failures — only on true shutdown
    3. Docs: document that webhook mode still runs a transport that can trigger deleteWebhook on rebuild, and recommend a guard mechanism for production deployments
  4. travellingsoldier85 commented on Jun 4, 2026

    @travellingsoldier85
    Author

    Update: 6-hour diagnostic evidence — confirmed ~32s clear cadence

    Environment: OpenClaw 2026.6.1, Ubuntu 24.04, webhook mode (webhookUrl set, actions.poll: false)

    What we now know with certainty

    After running a webhook guard script (which calls getWebhookInfo every 15s and re-asserts via setWebhook when cleared, never calling getUpdates), we have 6 hours of continuous data:

    Metric Value
    Total re-assertions 639
    Monitoring window 2026-06-04T08:00Z → 14:02Z (6.0 hours)
    Clear cadence (last 20 intervals, seconds) [32, 32, 31, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 30]
    Mean interval 31.8s
    Min / Max 30s / 32s

    The cadence is extremely regular — almost exactly 32s, not random. This strongly suggests a fixed-interval timer inside the gateway transport layer, not a stochastic event.

    What does NOT cause it

    • actions.poll: false is set — does not stop the clearing (per L-TG-WEBHOOK-ACTIONS-POLL-1 — this controls poll message types only, not the transport)
    • There is no duplicate poller — getUpdates with the same token returns ok: true with no 409 conflict; only one gateway PID exists
    • The guard never calls getUpdates — proof: when the guard runs and the webhook is set, getWebhookInfo still returns the URL correctly. The clear only happens on the ~32s boundary.

    Hypothesis on root cause

    Based on code strings observed in the gateway binary:

    • "polling so getUpdates can confirm webhook state"
    • "polling mode: clearing webhook"
    • monitor-webhook.runtime liveness/stall watchdog

    The monitor-webhook.runtime transport liveness timer appears to fire every ~32s and either calls getUpdates or triggers deleteWebhook via an abortSignal during transport rebuild. Since Telegram auto-deletes any registered webhook the moment getUpdates is called, this completely neutralises the webhook.

    actions.poll: false appears to only disable the poll message type delivery, not the transport liveness probe itself.

    Impact

    Without the guard timer, all inbound Telegram DMs are lost within ~32 seconds of any gateway start or config reload. The only mitigation is the 15s guard re-assertion loop, which is a band-aid racing the transport defect.

    Request

    1. Is there a config flag that disables the monitor-webhook.runtime liveness probe (or sets its interval to 0) when webhookUrl is configured?
    2. If not, can the webhook transport be made to skip getUpdates/deleteWebhook in the liveness cycle when webhookUrl is set?

    Happy to provide any additional diagnostics (gateway logs, binary strings, etc.).

  5. added
    P2Normal backlog priority with limited blast radius.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    and removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on Jun 15, 2026
  6. added a commit that references this issue on Jun 21, 2026
    ab14442
  7. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions