fix(telegram): drain outbound queue after polling reconnect#82227
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. at source level: current main's Telegram poll-success path only notes status and never invokes the shared reconnect drain. I did not establish a live stale-socket pending-delivery replay in this read-only pass. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Keep the reconnect drain, but make bypassBackoff depend only on duplicate-safe pre-connect evidence or leave backoff in place, then add redacted live proof that a queued Telegram delivery drains after reconnect. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main's Telegram poll-success path only notes status and never invokes the shared reconnect drain. I did not establish a live stale-socket pending-delivery replay in this read-only pass. Is this the best way to solve the issue? No, not yet. The reconnect hook is at the right ownership boundary, but the retry-bypass predicate should preserve Telegram's duplicate-safe send contract before this can merge. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 7715b29aa231. Re-review progress:
|
3b7f3db to
258190d
Compare
…#82227) * fix(telegram): drain outbound queue after polling reconnect * fix(telegram): keep reconnect drain backoff-safe
…#82227) * fix(telegram): drain outbound queue after polling reconnect * fix(telegram): keep reconnect drain backoff-safe
…#82227) * fix(telegram): drain outbound queue after polling reconnect * fix(telegram): keep reconnect drain backoff-safe
…#82227) * fix(telegram): drain outbound queue after polling reconnect * fix(telegram): keep reconnect drain backoff-safe
Summary
getUpdatesactivity.Problem
#50040 reports Telegram outbound reliability failures where network or stale-socket recovery can leave failed outbound replies in the durable delivery queue until a full gateway startup recovery happens. Current
mainalready has Telegram transport dirty-rebuild/polling-stall recovery and the generic reconnect drain used by WhatsApp, but Telegram did not call that drain after polling recovered.#82175 is related because stale-socket health recovery is the path that can restart Telegram polling without a full gateway restart. This PR does not claim to solve every health-state semantic in #82175; it closes the missing outbound recovery step once Telegram polling proves fresh transport liveness.
#82194 is separate: it is a direct-chat context dedupe PR for #82040, not a stale-socket or outbound delivery recovery fix.
Fixes #50040.
Refs #82175.
Refs #82194.
Real behavior proof
Behavior addressed: Telegram polling reconnect now schedules delivery-queue recovery after successful
getUpdatesliveness, including isolated ingress poll success, and repeats on later poll successes so same-cycle failures are not stranded.Real environment tested: Mantis Telegram Live on branch
fix/telegram-reconnect-delivery-drain, first candidate SHA3b7f3dbd6b6e7db5c2da4efcd11348d5469145c2, using Convex-leased Telegram credentials and a Crabbox desktop transcript capture; current head SHA258190d81f48b48d82ddad96ec93b6835aabbcafadds the backoff-safety fixup verified by focused tests and Codex review.Exact steps or command run after this patch: GitHub Actions workflow
Mantis Telegram Live, run https://github.com/openclaw/openclaw/actions/runs/25930493495, scenariotelegram-status-command; localnode scripts/run-vitest.mjs extensions/telegram/src/polling-session.test.ts src/infra/outbound/delivery-queue.reconnect-drain.test.ts extensions/telegram/src/network-errors.test.ts.Evidence after fix: Live Telegram artifacts from run https://github.com/openclaw/openclaw/actions/runs/25930493495 include screenshot/video/transcript files and
telegram-qa-summary.json; the summary reportstelegram-canarypass with reply matched in 1595ms andtelegram-status-commandpass with reply matched in 3604ms. The workflow conclusion is failed only after artifact upload because PR auto-comment token creation returnedInvalid keyData.Observed result after fix: Real Telegram bot replied to canary and
/statuson the branch SHA; focused tests confirm reconnect drain scheduling, account scoping, backoff-safe ambiguous send-error handling, isolated ingress poll-success drain, and repeated drain scheduling after later successfulgetUpdatescalls.What was not tested: forced live stale-socket wedge / real Telegram pending-outbound replay injection on this branch.
Codex review:
/Users/steipete/Projects/agent-scripts/skills/codex-review/scripts/codex-review --parallel-tests "node scripts/run-vitest.mjs extensions/telegram/src/polling-session.test.ts src/infra/outbound/delivery-queue.reconnect-drain.test.ts extensions/telegram/src/network-errors.test.ts"returned clean after accepted findings were fixed.