fix(telegram): honour retry_after on 429 instead of the library's fixed backoff #537

Closed
opened 2026-10-27 13:36:43 +00:00 by sam · 0 comments
Owner

go-telegram/bot v1.22.0 get_updates.go discards TooManyRequestsError.RetryAfter and applies its own 100ms-doubling backoff capped at 5s. Against retry_after:5 that is ~12 further requests inside the silence window, which escalated a brief 429 on carina into sustained 429s, 502s and request timeouts over several minutes.

Fixed in internal/channels/telegram/ratelimit.go: WithErrorsHandler is invoked synchronously from the polling loop before the library applies its own backoff, so blocking there honours the interval without patching the dependency. errors.As unwraps the library's fmt.Errorf wrap; capped at maxRetryAfter=60s; releases immediately on context cancellation so /restart during a 429 does not block.

Upstream report drafted for https://github.com/go-telegram/bot/issues -- suggested fix is to prefer RetryAfter over incErrTimeout in the error branch.


Imported from beads archie-core-1786637489959-7-6c8cdec2 · GitHub #28 · type task · priority P2 · created 2026-08-08 · closed 2026-08-08

go-telegram/bot v1.22.0 get_updates.go discards TooManyRequestsError.RetryAfter and applies its own 100ms-doubling backoff capped at 5s. Against retry_after:5 that is ~12 further requests inside the silence window, which escalated a brief 429 on carina into sustained 429s, 502s and request timeouts over several minutes. Fixed in internal/channels/telegram/ratelimit.go: WithErrorsHandler is invoked synchronously from the polling loop before the library applies its own backoff, so blocking there honours the interval without patching the dependency. errors.As unwraps the library's fmt.Errorf wrap; capped at maxRetryAfter=60s; releases immediately on context cancellation so /restart during a 429 does not block. Upstream report drafted for https://github.com/go-telegram/bot/issues -- suggested fix is to prefer RetryAfter over incErrTimeout in the error branch. --- _Imported from beads `archie-core-1786637489959-7-6c8cdec2` · GitHub #28 · type task · priority P2 · created 2026-08-08 · closed 2026-08-08_
sam added the mediumtask labels 2026-10-27 13:36:43 +00:00
sam self-assigned this 2026-10-27 13:36:43 +00:00
sam closed this issue 2026-10-27 13:36:43 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#537