Handle serializer errors on connect
This commit is contained in:
parent
33a8218eee
commit
587ec98f3e
|
@ -240,13 +240,17 @@ class Client:
|
|||
self.user.oauth_credential = oauth_info.credential
|
||||
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.
|
||||
Receive a snapshot of account state in response.
|
||||
"""
|
||||
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}"
|
||||
try:
|
||||
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}"
|
||||
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
|
||||
self._start_listen()
|
||||
return login_result
|
||||
|
|
|
@ -412,7 +412,8 @@ class User(DBUser, BaseUser):
|
|||
try:
|
||||
login_result = await self.client.connect()
|
||||
await self.on_connect()
|
||||
await self._sync_channels(login_result, sync_count)
|
||||
if login_result:
|
||||
await self._sync_channels(login_result, sync_count)
|
||||
return True
|
||||
except AuthenticationRequired as e:
|
||||
await self.send_bridge_notice(
|
||||
|
|
Loading…
Reference in New Issue