diff --git a/telethon/tl/custom/conversation.py b/telethon/tl/custom/conversation.py index 570707e9..5a4a71cf 100644 --- a/telethon/tl/custom/conversation.py +++ b/telethon/tl/custom/conversation.py @@ -338,10 +338,10 @@ class Conversation(ChatGetter): self._custom[counter] = (event, future) try: return await self._get_result(future, start_time, timeout, self._custom, counter) - except asyncio.TimeoutError: + finally: # Need to remove it from the dict if it times out, else we may # try and fail to set the result later (#1618). - del self._custom[counter] + self._custom.pop(counter, None) async def _check_custom(self, built): for key, (ev, fut) in list(self._custom.items()):