Explorar o código

Retry non-JSON responses when getting current user

Nick Barrett %!s(int64=2) %!d(string=hai) anos
pai
achega
f3aeb8daba
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      mautrix_instagram/user.py

+ 11 - 0
mautrix_instagram/user.py

@@ -29,6 +29,7 @@ from mauigpapi.errors import (
     IGConsentRequiredError,
     IGNotLoggedInError,
     IGRateLimitError,
+    IGUnknownError,
     IGUserIDNotFoundError,
     IrisSubscribeError,
     MQTTConnectionUnauthorized,
@@ -888,6 +889,16 @@ class User(DBUser, BaseUser):
             except (IGChallengeError, IGConsentRequiredError) as e:
                 await self._handle_checkpoint(e, on="reconnect")
                 return
+            except IGUnknownError as e:
+                if "non-JSON body" not in e:
+                    raise
+                errors += 1
+                if errors > 10:
+                    raise
+                self.log.warning(
+                    "Non-JSON body while trying to check user for reconnection, retrying in 10s"
+                )
+                await asyncio.sleep(10)
             except Exception as e:
                 self.log.exception("Error while reconnecting to Instagram")
                 if isinstance(e, IGCheckpointError):