Repository navigation
fix(channels): keep Telegram polling after a bad getUpdates batch - #112
Draft
cursor[bot] wants to merge 1 commit into
Draft
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
getUpdates used the API default of 100 updates. A backlog larger than the 256 KiB response buffer made curl abort before the offset advanced, so every later poll retried the same batch and the inbox stalled. Messages that omit from.id returned a hard error and pinned the same way. Request one update per poll, and skip a message with no sender id so the following update can be fetched. Co-authored-by: esadrianno <esadrianno@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
Telegram
getUpdatescould stall the channel permanently, so later user messages were never delivered.Two concrete triggers:
limit, so Telegram returned up to 100 updates.write_cbrejects bodies over 256 KiB. A backlog of long messages (for example while an agent turn is in progress) makes curl abort with a write error.tg_pollthen returns without movinglast_update_id, and every later poll retries the same batch.messagewith no numericfrom.id(channel posts and some anonymous-admin messages) madeparse_updatereturn -1. The poll loop does not advance the offset on that error, so that update stayed at the head of the queue and blocked everything after it.Root cause
src/channels/telegram.ctg_poll/parse_update: the client consumed onlyresult[0]but accepted the API's 100-update default, and structural skips were reported as hard failures that leave the offset unchanged.Fix
limit=1, which matches the single-update parser and keeps each body well under the 256 KiB cap.return 0) after recording itsupdate_id, so the next poll fetches the following update.Validation
make test_telegramfailed on the new cases before the fix (missingfromstill returned -1, and the getUpdates URL had nolimit=1) and passes after it: 42 tests, 0 failed.