Skip to content

test(telegram): keep live polling leases protected#93378

Merged
obviyus merged 1 commit into
openclaw:mainfrom
mmyzwl:fix/issue-93375-telegram-polling-crash-loop
Jun 22, 2026
Merged

test(telegram): keep live polling leases protected#93378
obviyus merged 1 commit into
openclaw:mainfrom
mmyzwl:fix/issue-93375-telegram-polling-crash-loop

Conversation

@mmyzwl

@mmyzwl mmyzwl commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Keep Telegram's same-token polling lease protection intact and add regression coverage for the reviewed failure mode.

This no longer claims to fix #93375. The attempted lease-age recovery was removed because a healthy Telegram poller can hold a non-aborted lease for longer than five minutes, so lease age is not a safe owner-death signal.

What changed

  • Removed the five-minute active-lease replacement path.
  • Added a regression test proving an old but still-active same-token lease continues to reject a duplicate poller.

Verification

  • node scripts/run-vitest.mjs extensions/telegram/src/polling-lease.test.ts
  • ./node_modules/.bin/oxfmt --check --threads=1 extensions/telegram/src/polling-lease.ts extensions/telegram/src/polling-lease.test.ts
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/telegram/src/polling-lease.ts extensions/telegram/src/polling-lease.test.ts
  • .agents/skills/autoreview/scripts/autoreview --mode local --prompt "Scope: PR 93378 maintainer cleanup. Removed unsafe age-based Telegram polling lease replacement, added one focused regression test that old non-aborted same-token leases still reject duplicates. Please review only extensions/telegram/src/polling-lease.ts and polling-lease.test.ts changes."

Not fixed

#93375 remains open. The recovery fix should use explicit stopped/aborted lifecycle state or gateway task cleanup, with real Telegram or equivalent runtime proof.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 20, 2026, 3:37 PM ET / 19:37 UTC.

Summary
The PR changes Telegram polling lease acquisition to delete and reacquire a same-token non-aborted lease once it is older than five minutes.

PR surface: Source +9. Total +9 across 1 file.

Reproducibility: yes. for the PR-introduced regression at source level: current main lets a healthy Telegram poller hold a non-aborted lease indefinitely, so this PR would replace it after five minutes. The original transient-timeout crash loop still needs live or equivalent proof for the exact recovery path.

Review metrics: 1 noteworthy metric.

  • Lease Replacement Threshold: 1 added five-minute replacement path. The new timeout changes when Telegram's same-token duplicate-poller guard yields, which is message-delivery-sensitive before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #93375
Summary: This PR is an unsafe candidate fix for the open Telegram crash-loop issue, while overlapping broader gateway lifecycle and Telegram getUpdates recovery work that remains unresolved.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Keep non-aborted same-token leases protected, including coverage for a live lease older than five minutes.
  • [P1] Add redacted live Telegram, gateway-log, terminal, or equivalent transport proof showing recovery without duplicate same-token pollers.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body supplies simulated steps and a unit-test result, but needs redacted live Telegram, gateway-log, terminal, or equivalent runtime proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A live Telegram polling recovery probe would materially help prove recovery without creating competing same-token pollers. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram live: verify stale Telegram polling recovery after a transient getUpdates timeout and confirm no duplicate same-token poller starts while the original poller is still alive.

Risk before merge

  • [P1] Merging this PR as written can let a second same-token Telegram poller replace an already-running first poller after five minutes, risking getUpdates conflicts and lost or stalled inbound delivery.
  • [P1] The PR body’s evidence is simulated/unit-test output only; it does not show a real or equivalent Telegram transport recovery path after the patch.
  • [P0] The linked outage includes broader gateway lifecycle evidence, so a lease-age-only fix may miss the actual stopped/restartPending recovery boundary.

Maintainer options:

  1. Keep Active Lease Protection (recommended)
    Change the branch so non-aborted same-token leases continue to reject duplicates, and recover only from explicit stopped or aborted lifecycle state.
  2. Move Recovery To Gateway Lifecycle
    Pause this lease-age change and solve the linked outage through the gateway stop-timeout or health-monitor recovery path with real runtime proof.
  3. Accept Duplicate-Poller Risk Explicitly
    Maintainers could intentionally accept age-based replacement, but that should require live proof that it cannot start competing same-token pollers.

Next step before merge

  • [P1] Human lifecycle review is needed because the safe repair boundary is not a narrow lease-age edit and contributor-side real behavior proof is still missing.

Security
Cleared: No concrete security or supply-chain concern was found; the diff only changes in-process Telegram lease acquisition logic.

Review findings

  • [P1] Keep refusing live leases after five minutes — extensions/telegram/src/polling-lease.ts:164-174
Review details

Best possible solution:

Preserve active duplicate-poller protection and solve recovery through explicit stopped or aborted lifecycle state, or through the gateway stale-task recovery path, with redacted real Telegram or equivalent runtime proof.

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

Yes for the PR-introduced regression at source level: current main lets a healthy Telegram poller hold a non-aborted lease indefinitely, so this PR would replace it after five minutes. The original transient-timeout crash loop still needs live or equivalent proof for the exact recovery path.

Is this the best way to solve the issue?

No. Lease age is not a safe owner-death signal for a long-running poller; explicit stopped/aborted lifecycle state or gateway-owned stale-task recovery is the safer fix boundary.

Full review comments:

  • [P1] Keep refusing live leases after five minutes — extensions/telegram/src/polling-lease.ts:164-174
    A normal Telegram monitor acquires this lease before runUntilAbort() and releases it only after that loop exits, so a healthy poller can hold a non-aborted lease longer than five minutes. Deleting that entry by age lets a second same-token poller start, risking getUpdates conflicts or missed inbound delivery; only explicit stopped or aborted lifecycle state should permit replacement.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The PR targets a real Telegram polling outage where inbound channel delivery can remain down until a full gateway restart.
  • merge-risk: 🚨 message-delivery: The diff changes the guard that prevents competing same-token Telegram pollers from consuming updates concurrently.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body supplies simulated steps and a unit-test result, but needs redacted live Telegram, gateway-log, terminal, or equivalent runtime proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +9. Total +9 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 14 5 +9
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 14 5 +9

What I checked:

  • Repository policy applied: Root AGENTS.md and the scoped extensions guide were read; Telegram behavior PRs need source, sibling tests, and real Telegram or equivalent proof for transport changes. (AGENTS.md:28, 7b9ddbda997a)
  • PR diff changes active-lease behavior: The patch replaces the duplicate-polling throw for a non-aborted same-token lease with a five-minute age check that deletes the registry entry and continues acquisition. (extensions/telegram/src/polling-lease.ts:164, ec92e88feb87)
  • Current main protects non-aborted leases: Current main treats an existing same-token lease with no aborted signal as active and throws the duplicate-polling error before any replacement path. (extensions/telegram/src/polling-lease.ts:160, 7b9ddbda997a)
  • Runtime caller holds the lease for session lifetime: monitorTelegramProvider acquires the lease before creating TelegramPollingSession and releases it only after runUntilAbort returns. (extensions/telegram/src/monitor.ts:207, 7b9ddbda997a)
  • Polling session is intentionally long-lived: TelegramPollingSession.runUntilAbort loops while the provider abort signal is not aborted, so a healthy poller can hold a non-aborted lease far longer than five minutes. (extensions/telegram/src/polling-session.ts:378, 7b9ddbda997a)
  • Existing tests encode the duplicate-poller invariant: Current monitor and lease tests assert concurrent same-token polling is refused and non-aborted active leases are not released. (extensions/telegram/src/monitor.test.ts:637, 7b9ddbda997a)

Likely related people:

  • joshavant: Authored and merged the stopped Telegram polling lease cleanup and tests on the same helper while preserving active duplicate protection. (role: recent lease cleanup contributor; confidence: high; commits: 726b0b53f5c5; files: extensions/telegram/src/polling-lease.ts, extensions/telegram/src/polling-lease.test.ts, extensions/telegram/src/channel.ts)
  • obviyus: Authored merged Telegram polling liveness work and later queued recovery-start behavior in adjacent channel lifecycle paths. (role: recent Telegram and gateway recovery contributor; confidence: high; commits: 5d15b13b65b2, 02b80ea1d22b; files: extensions/telegram/src/polling-session.ts, extensions/telegram/src/polling-liveness.ts, src/gateway/server-channels.ts)
  • kevinslin: Authored merged gateway stop-timeout recovery work in the same channel manager and health monitor area implicated by the linked issue. (role: adjacent recovery-stop fix author; confidence: high; commits: d55639a92d51, b77aec55c2bc; files: src/gateway/server-channels.ts, src/gateway/channel-health-monitor.ts, src/gateway/server-channels.test.ts)
  • vincentkoc: Current compact blame maps the central Telegram lease/monitor lines to a recent snapshot under this name, and live review comments show maintainer review on the stale-lease and gateway recovery direction. (role: recent area contributor and reviewer; confidence: medium; commits: 3df4341e5af9; files: extensions/telegram/src/polling-lease.ts, extensions/telegram/src/monitor.ts, src/gateway/server-channels.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 15, 2026
@obviyus obviyus changed the title #93375: fix(telegram): recover from stale polling lease after crash loop test(telegram): keep live polling leases protected Jun 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 22, 2026
@obviyus obviyus force-pushed the fix/issue-93375-telegram-polling-crash-loop branch from 94e2c6b to 2c0bddd Compare June 22, 2026 05:34
@obviyus obviyus merged commit b3b8b28 into openclaw:main Jun 22, 2026
18 of 19 checks passed
@obviyus

obviyus commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Landed via rebase onto main.

  • Scoped tests: node scripts/run-vitest.mjs extensions/telegram/src/polling-lease.test.ts
  • Format: ./node_modules/.bin/oxfmt --check --threads=1 extensions/telegram/src/polling-lease.test.ts
  • Lint: node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/telegram/src/polling-lease.test.ts
  • Changelog: not user-facing; test-only regression coverage
  • Land commit: 2c0bddd
  • Merge commit: b3b8b28

Thanks @mmyzwl!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram polling enters silent crash loop after transient network timeout — health monitor cannot recover

2 participants