Repository navigation
fix(telegram): match grammY HttpError in retry regex - #51589
Matthew19990919 wants to merge 1 commit into
Conversation
grammY wraps network errors in HttpError with messages like "Network request for 'sendMessage' failed!" which contains none of the existing TELEGRAM_RETRY_RE keywords. Add "network request" to the regex so these transient failures trigger the retry path. Closes #51525 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Greptile SummaryThis PR fixes a bug where grammY's
Confidence Score: 5/5
Last reviewed commit: "fix(telegram): match..." |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e3bfbd38a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const TELEGRAM_RETRY_RE = | ||
| /429|timeout|connect|reset|closed|unavailable|temporarily|network request/i; |
There was a problem hiding this comment.
Exclude non-idempotent sticker sends from the new regex retry path
Adding network request to the shared fallback regex now retries every Telegram call site that does not set strictShouldRetry. sendStickerTelegram still goes through createTelegramRequestWithDiag rather than createTelegramNonIdempotentRequestWithDiag (extensions/telegram/src/send.ts:1448 vs extensions/telegram/src/send.ts:550), so a grammY HttpError("Network request for 'sendSticker' failed!") will now replay sendSticker. In the common lost-response case where Telegram accepted the first sticker before the socket broke, this turns a single delivery into duplicate stickers for end users.
Useful? React with 👍 / 👎.
Summary
network requesttoTELEGRAM_RETRY_REso grammYHttpErrormessages trigger the retry pathRoot Cause
grammY wraps underlying network errors in
HttpErrorwith the message:This string contains none of the existing
TELEGRAM_RETRY_REkeywords (429|timeout|connect|reset|closed|unavailable|temporarily), soshouldRetryreturnsfalseand retries never fire — even though the underlying cause is a transient network failure (ECONNRESET, UND_ERR_CONNECT_TIMEOUT, etc.).Fix
Add
network requestto the regex. This matches grammY'sHttpErrormessage format at the top level without needing to traverse.cause, keeping the change minimal and backwards-compatible.The
strictShouldRetryguard for non-idempotent operations (e.g.sendMessage) is unaffected — the regex fallback is only OR'd in for idempotent paths likesendChatAction,setReaction, anddeleteMessage.Test Plan
retries grammY HttpError wrapping network failures via regexstrictShouldRetry: truestill suppresses the regex fallbackCloses #51525