From 05d1fc9b78f4f83cebe822b59dbc9863339a1226 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 7 Nov 2022 17:33:50 +0530 Subject: [PATCH] chore: handle irrecoverable error --- src/Socket/chats.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 1d7c837..5389ef2 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -393,7 +393,9 @@ export const makeChatsSocket = (config: SocketConfig) => { } catch(error) { // if retry attempts overshoot // or key not found - const isIrrecoverableError = attemptsMap[name]! >= MAX_SYNC_ATTEMPTS || error.output?.statusCode === 404 + const isIrrecoverableError = attemptsMap[name]! >= MAX_SYNC_ATTEMPTS + || error.output?.statusCode === 404 + || error.message.includes('TypeError') logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`) await authState.keys.set({ 'app-state-sync-version': { [name]: null } }) // increment number of retries