Telethon
Telethon copied to clipboard
Updates not coming consistently with v1.24 branch
Hello, i opened 3-4 days ago an issue regarding update events not coming in consistently. I tried installing the branch as you advised me to do, but it only got worse: basically when the bot is ran it works correctly, gets the updates and the events get raised, but after a while it becomes unresponsive.
I have no logs that could reproduce the issue, beside this:
Telegram is having internal issues RpcCallFailError: Telegram is having internal issues, please try again later. (caused by GetChannelDifferenceRequest) .
I could send the full code I'm working on, but I don't think that could make the difference, anyway if it is required there's no problem to do so. The bot runs on a cloud machine, and I'm 100% sure it was connected at the time the event got raised.
I'm going to revert back to the release, but why is this?
Checklist
- [x] The error is in the library's code, and not in my own.
- [x] I have searched for this issue before posting it and there isn't a duplicate.
- [x] I ran
pip3 install -U https://github.com/LonamiWebs/Telethon/archive/v1.24.zip
and triggered the bug in the latest version.
Confirm.
There has been some fixes regarding update handling, particularly for bot accounts. I am going to close this issue since there's no particular error here that's crashing the update handling.
The new update handling should be recovering update gaps (something the old update handling did not). It should still dispatch every update coming in through the socket (much like the old system did). So I'm not sure why "updates could not be coming". If there are still issues in the v1.24 branch let me know (I am referring to commit 363c2604dfa7504c829f58be5c8a64448ffc4f62 and above).
@Lonami I've seen my bot (v1.25) facing both this issue and #3873 in production multiple times in the last 10 days.
#3873 should have been fixed in 2f2a9901e2d9ea0668c221c18820be5bfc8c94e2 but I am not sure since there has not been a new release for me to upgrade.
After reading the recent commit history, I didn't find any fix strongly corresponding to this issue. But my bot actually facing a very similar scenario, so here's my error log:
2022-09-08-17:34:35:WARNING:telethon.client.users - Telegram is having internal issues HistoryGetFailedError: Fetching of history failed (caused by GetChannelDifferenceRequest)
2022-09-08-17:34:37:WARNING:telethon.client.users - Telegram is having internal issues PersistentTimestampOutdatedError: Persistent timestamp outdated (caused by GetChannelDifferenceRequest)
2022-09-08-17:34:40:WARNING:telethon.client.users - Telegram is having internal issues HistoryGetFailedError: Fetching of history failed (caused by GetChannelDifferenceRequest)
2022-09-08-17:34:42:ERROR:telethon.client.updates - Fatal error handling updates (this is a bug in Telethon, please report it)
Traceback (most recent call last):
File "/opt/venv/lib/python3.10/site-packages/telethon/client/updates.py", line 281, in _update_loop
diff = await self(get_diff)
File "/opt/venv/lib/python3.10/site-packages/telethon/client/users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
File "/opt/venv/lib/python3.10/site-packages/telethon/client/users.py", line 129, in _call
raise last_error
File "/opt/venv/lib/python3.10/site-packages/telethon/client/users.py", line 84, in _call
result = await future
telethon.errors.rpcerrorlist.HistoryGetFailedError: Fetching of history failed (caused by GetChannelDifferenceRequest)
Every time this occurred, my bot no longer received incoming updates.
I suggest (no matter whether these bugs are fixed or not) that there should be an option to immediately raise or exit when a fatal error occurs during handling updates to avoid resulting in an unresponsive bot (especially when some external services will restart the bot on failure).
HistoryGetFailedError
, Telegram doesn't cease to surprise me. I guess that code should use a catch-all error 500 rather than specific ones.
Also I've just been cleaning up branches. master
is now v2
. v1.24
is now v1
, and is the default branch, in case some people here are still trying things around. Most older branches have been deleted in favour of just keeping tags to preserve the commits. The command to try now would be:
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip
I suggest (no matter whether these bugs are fixed or not) that there should be an option to immediately raise or exit when a fatal error occurs during handling updates to avoid resulting in an unresponsive bot
Yeah the client should probably raise that back up to the user so they can deal with it in any way they see fit. I can do that before the next version.
Thanks for your suggestion to try the latest snapshot. Unfortunately, I can't do that in production and I've never seen this bug in my local test. I would try adopting the latest snapshot in another less important bot. Waiting for the next release!
Sorry to break it to you but my releases never have really been extensively tested, I simply make them when I feel the code is in a decent spot. I primarily test the changes as I make them. So really current v1
branch is as good as a new release. But I understand your concern.
Uhh, the reason why I can't adopt a snapshot in production is just that I can't adopt a snapshot in the production docker image tag my production bot using because there are a lot of downstream image users too, but, meanwhile, I don't want to create another tag, lol.
Mixed with https://github.com/Rongronggg9/RSS-to-Telegram-Bot/commit/5e503f5dea7ba78623c2e0567e2decb1a3c04bde, I will enter my production container to upgrade telethon for test.