diff --git a/telethon/client/updates.py b/telethon/client/updates.py index 925b2b1b..ead9f944 100644 --- a/telethon/client/updates.py +++ b/telethon/client/updates.py @@ -341,6 +341,15 @@ class UpdateMethods: self._updates_error = e await self.disconnect() break + except errors.RPCError as e: + # Fallback; treat as transient error (the amount of "fatal errors" reported seem to indicate this is most likely what we need to do) + self._log[__name__].warning( + "Cannot get difference due to unexpected error (this may be a bug " + f"in Telethon v{__version__} in that it could be handled better, but it's unlikely): %s", + e + ) + self._message_box.end_difference() + continue except OSError as e: # Network is likely down, but it's unclear for how long. # If disconnect is called this task will be cancelled along with the sleep. @@ -439,6 +448,19 @@ class UpdateMethods: self._mb_entity_cache ) continue + except errors.RPCError as e: + # Fallback; treat as transient error (the amount of "fatal errors" reported seem to indicate this is most likely what we need to do) + self._log[__name__].warning( + "Cannot get difference for channel %d due to unexpected error (this may be a bug " + f"in Telethon v{__version__} in that it could be handled better, but it's unlikely): %s", + get_diff.channel.channel_id, e + ) + self._message_box.end_channel_difference( + get_diff, + PrematureEndReason.TEMPORARY_SERVER_ISSUES, + self._mb_entity_cache + ) + continue except OSError as e: self._log[__name__].info( 'Cannot get difference for channel %d since the network is down: %s: %s',