Skip to content

Commit

Permalink
except and propagate TypeNotFoundError during update handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed May 3, 2023
1 parent 9c7ac3b commit 2889bd5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions telethon/client/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ async def _update_loop(self: 'TelegramClient'):
await self.disconnect()
break
continue
except errors.TypeNotFoundError as e:
# User is likely doing weird things with their account or session and Telegram gets confused as to what layer they use
self._log[__name__].warning('Cannot get difference since the account is likely misusing the session: %s', e)
self._message_box.end_difference()
self._updates_error = e
await self.disconnect()
break
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.
Expand Down Expand Up @@ -354,6 +361,19 @@ async def _update_loop(self: 'TelegramClient'):
await self.disconnect()
break
continue
except errors.TypeNotFoundError as e:
self._log[__name__].warning(
'Cannot get difference since the account is likely misusing the session: %s',
get_diff.channel.channel_id, e
)
self._message_box.end_channel_difference(
get_diff,
PrematureEndReason.TEMPORARY_SERVER_ISSUES,
self._mb_entity_cache
)
self._updates_error = e
await self.disconnect()
break
except (
errors.PersistentTimestampOutdatedError,
errors.PersistentTimestampInvalidError,
Expand Down

0 comments on commit 2889bd5

Please sign in to comment.