Fix TypeNotFoundError was not being propagated

Closes #1697. This would cause deadlocks, as the request future
would never be resolved, so await would wait forever.
This commit is contained in:
Lonami Exo 2021-02-11 19:26:40 +01:00
parent 845fe88451
commit 8f0de3d285

View File

@ -610,11 +610,16 @@ class MTProtoSender:
if not state.future.cancelled(): if not state.future.cancelled():
state.future.set_exception(error) state.future.set_exception(error)
else: else:
with BinaryReader(rpc_result.body) as reader: try:
result = state.request.read_result(reader) with BinaryReader(rpc_result.body) as reader:
result = state.request.read_result(reader)
if not state.future.cancelled(): except Exception as e:
state.future.set_result(result) # 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): async def _handle_container(self, message):
""" """