Properly log RpcError with no parent request

This should get rid of the unexpected BufferError traceback.
This commit is contained in:
Lonami Exo 2022-05-31 11:02:34 +02:00
parent 0f5eeb29e7
commit 1af6d9a873

View File

@ -592,6 +592,14 @@ class MTProtoSender:
# However receiving a File() with empty bytes is "common". # However receiving a File() with empty bytes is "common".
# See #658, #759 and #958. They seem to happen in a container # See #658, #759 and #958. They seem to happen in a container
# which contain the real response right after. # which contain the real response right after.
#
# But, it might also happen that we get an *error* for no parent request.
# If that's the case attempting to read from body which is None would fail with:
# "BufferError: No more data left to read (need 4, got 0: b''); last read None".
# This seems to be particularly common for "RpcError(error_code=-500, error_message='No workers running')".
if rpc_result.error:
self._log.info('Received error without parent request: %s', rpc_result.error)
else:
try: try:
with BinaryReader(rpc_result.body) as reader: with BinaryReader(rpc_result.body) as reader:
if not isinstance(reader.tgread_object(), upload.File): if not isinstance(reader.tgread_object(), upload.File):