Catch-all unknown RPCError and treat them as transient during getDifference

Can be considered to close #4739.
This commit is contained in:
Lonami Exo
2026-02-01 20:38:22 +01:00
parent 416570fdf0
commit d57be746f9

View File

@@ -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',