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,9 +610,14 @@ class MTProtoSender:
if not state.future.cancelled(): if not state.future.cancelled():
state.future.set_exception(error) state.future.set_exception(error)
else: else:
try:
with BinaryReader(rpc_result.body) as reader: with BinaryReader(rpc_result.body) as reader:
result = state.request.read_result(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(): if not state.future.cancelled():
state.future.set_result(result) state.future.set_result(result)