Skip to content

Commit

Permalink
Fix TypeNotFoundError was not being propagated
Browse files Browse the repository at this point in the history
Closes #1697. This would cause deadlocks, as the request future
would never be resolved, so await would wait forever.
  • Loading branch information
Lonami committed Feb 11, 2021
1 parent 845fe88 commit 8f0de3d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions telethon/network/mtprotosender.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,16 @@ async def _handle_rpc_result(self, message):
if not state.future.cancelled():
state.future.set_exception(error)
else:
with BinaryReader(rpc_result.body) as reader:
result = state.request.read_result(reader)

if not state.future.cancelled():
state.future.set_result(result)
try:
with BinaryReader(rpc_result.body) as reader:
result = state.request.read_result(reader)
except Exception as e:
# e.g. TypeNotFoundError, should be propagated to caller
if not state.future.cancelled():
state.future.set_exception(e)
else:
if not state.future.cancelled():
state.future.set_result(result)

async def _handle_container(self, message):
"""
Expand Down

0 comments on commit 8f0de3d

Please sign in to comment.