Repository navigation
fix(telegram): survive transient getUpdates errors and stop per-send cache rewrites - #98775
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 6:20 PM ET / 22:20 UTC. Summary PR surface: Source +108, Tests +208. Total +316 across 8 files. Reproducibility: yes. at source level: current main rewrites every cached sent-message row on each send and current isolated getUpdates handling rethrows 429/5xx/non-JSON failures because the retry gate does not classify them as recoverable. I did not run a live Telegram degradation replay in this read-only review. Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this bounded Telegram retry/cache repair after maintainer acceptance of the transport-proof gap and retry_after bound, then let the linked issues close through the merged PR. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main rewrites every cached sent-message row on each send and current isolated getUpdates handling rethrows 429/5xx/non-JSON failures because the retry gate does not classify them as recoverable. I did not run a live Telegram degradation replay in this read-only review. Is this the best way to solve the issue? Yes: the PR fixes the implicated owner boundaries by keeping retry classification in the Telegram worker/network-error layer and narrowing cache persistence to the one new entry. The remaining question is merge proof depth and operational acceptance, not a different implementation layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against eb417fa206e6. Label changesLabel justifications:
Evidence reviewedPR surface: Source +108, Tests +208. Total +316 across 8 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
c82e50d to
84ee4a6
Compare
|
Landed via rebase onto main.
|
Closes #98772
Closes #98773
What Problem This Solves
Fixes two Telegram channel stability defects found in a full subsystem audit:
getUpdates(429, 500, 502 — including 502s with HTML bodies) crashed the account's polling session. Because the gateway supervisor counts restart attempts cumulatively, routine Telegram degradations eventually disabled the channel permanently until a manual restart. This was a regression from the isolated-ingress migration: the retired grammY polling path retried these errors internally for up to an hour.Why This Change Was Made
The ingress worker now classifies Bot API server errors (5xx) and rate limits (429) as retryable, honoring
parameters.retry_afterbefore falling back to the existing exponential backoff, and parses non-2xx bodies defensively so a 502 HTML page becomes a status-bearing retryable error instead of a fatalJSON.parsecrash. 401/404 stay fatal (bad token) and 409 still propagates to the parent session, which owns webhook-conflict recovery. The classifier is shared with the webhook registration path, which already had this behavior (pure refactor there, no behavior change). The sent-message cache now persists only the newly recorded entry — keys were already content-addressed — relying on per-entry TTL and store-side caps for expiry.The worker runtime was extracted into an injectable function (module-level side effects gated behind a workerData marker) so the retry behavior is directly testable.
User Impact
Telegram accounts survive Telegram-side outages and rate limiting instead of dying permanently, and 429
retry_afterhints are respected on the polling path. Busy bots no longer degrade the whole gateway as their daily send volume grows; spurious stall-watchdog restarts from event-loop blocking disappear.Known bound, not a bug: an extreme
retry_after(e.g. 3600s) makes the worker sleep past the parent stall watchdog, which restarts the session — an acceptable upper bound that converges.Evidence
extensions/telegram/src/telegram-ingress-worker.runtime.test.ts: 429-with-retry_afterretries after the hinted delay; 500/502 retry with backoff; 502 HTML body (JSON parse failure) retries; 401 and 409 still propagate to the parent.extensions/telegram/src/send.test.tsnow asserts exactly one persisted entry per recorded sent message.pnpm tsgo:extensionspass;node scripts/run-vitest.mjson all touched test files — 204 tests pass (send, network-errors, ingress-worker runtime); repo autoreview clean.codex/fix-telegram-spool): conflict-free octopus merge,pnpm tsgo:extensionspass, 403/403 tests across all six touched test files.