From 44bf8427249cd125c027820ff516262701bb58c0 Mon Sep 17 00:00:00 2001 From: Adhiraj Date: Thu, 30 Jul 2020 20:38:30 +0530 Subject: [PATCH] connect fail bug fix --- src/WAConnection/Connect.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/WAConnection/Connect.ts b/src/WAConnection/Connect.ts index 65f6bf3..3d1324e 100644 --- a/src/WAConnection/Connect.ts +++ b/src/WAConnection/Connect.ts @@ -12,9 +12,14 @@ export default class WAConnectionConnector extends WAConnectionValidator { * @return returns [userMetaData, chats, contacts, unreadMessages] */ async connect(authInfo: AuthenticationCredentialsBase64 | string = null, timeoutMs: number = null) { - const userInfo = await this.connectSlim(authInfo, timeoutMs) - const chats = await this.receiveChatsAndContacts(timeoutMs) - return [userInfo, ...chats] as [UserMetaData, WAChat[], WAContact[], WAMessage[]] + try { + const userInfo = await this.connectSlim(authInfo, timeoutMs) + const chats = await this.receiveChatsAndContacts(timeoutMs) + return [userInfo, ...chats] as [UserMetaData, WAChat[], WAContact[], WAMessage[]] + } catch (error) { + this.close () + throw error + } } /** * Connect to WhatsAppWeb, resolves without waiting for chats & contacts