fix(telegram): drain pending updates before polling to prevent 409 Conflict#425
Open
fix(telegram): drain pending updates before polling to prevent 409 Conflict#425
Conversation
…nflict When migrating to go-telegram/bot library (commit 1104739), the drain step that clears pending updates was removed. This causes 409 Conflict errors on restart because Telegram still considers the previous instance's long-poll request as active. The fix adds drainPendingUpdates() which calls getUpdates with offset=-1 before starting the polling loop. This terminates any outstanding long-poll request from a previous instance. Fixes #422 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
|
LGTM! Clean fix for the 409 Conflict issue on Telegram bot restart. ✅ Correctness: The function correctly calls to clear any outstanding long-poll request from a previous instance. ✅ Implementation: Good error handling with debug logging, proper context timeout, and response body cleanup. ✅ CI: All checks pass. ✅ Scope: Focused single-purpose fix, references the root cause (migration to go-telegram/bot library). Ready for merge. |
chenhg5
commented
Apr 3, 2026
Owner
Author
chenhg5
left a comment
There was a problem hiding this comment.
QA review passed. Clean fix for 409 Conflict on Telegram bot restart.
Review summary:
- ✅
drainPendingUpdates()calls getUpdates with offset=-1 before polling - ✅ Terminates outstanding long-poll from previous instance
- ✅ Proper timeout and error handling
- ✅ CI passes
Ready to merge (owner PR).
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.
Summary
drainPendingUpdates()function that callsgetUpdates?offset=-1&timeout=0before starting the polling loopTest plan
go build ./...go test ./...Fixes #422
🤖 Generated with Claude Code