Handle serializer errors on connect

This commit is contained in:
Andrew Ferrazzutti 2022-04-12 04:17:18 -04:00
parent 33a8218eee
commit 587ec98f3e
2 changed files with 9 additions and 4 deletions

View File

@ -240,13 +240,17 @@ class Client:
self.user.oauth_credential = oauth_info.credential self.user.oauth_credential = oauth_info.credential
await self.user.save() await self.user.save()
async def connect(self) -> LoginResult: async def connect(self) -> LoginResult | None:
""" """
Start a new talk session by providing a token obtained from a prior login. Start a new talk session by providing a token obtained from a prior login.
Receive a snapshot of account state in response. Receive a snapshot of account state in response.
""" """
try:
login_result = await self._api_user_request_result(LoginResult, "connect") login_result = await self._api_user_request_result(LoginResult, "connect")
assert self.user.ktid == login_result.userId, f"User ID mismatch: expected {self.user.ktid}, got {login_result.userId}" assert self.user.ktid == login_result.userId, f"User ID mismatch: expected {self.user.ktid}, got {login_result.userId}"
except SerializerError:
self.log.exception("Unable to deserialize login result, but connecting anyways")
login_result = None
# TODO Skip if handlers are already listening. But this is idempotent and thus probably safe # TODO Skip if handlers are already listening. But this is idempotent and thus probably safe
self._start_listen() self._start_listen()
return login_result return login_result

View File

@ -412,6 +412,7 @@ class User(DBUser, BaseUser):
try: try:
login_result = await self.client.connect() login_result = await self.client.connect()
await self.on_connect() await self.on_connect()
if login_result:
await self._sync_channels(login_result, sync_count) await self._sync_channels(login_result, sync_count)
return True return True
except AuthenticationRequired as e: except AuthenticationRequired as e: