From 22af9df3d005560039054e6dae5c60a6b821682b Mon Sep 17 00:00:00 2001 From: Ayush Mourya <50497558+ayushmourya@users.noreply.github.com> Date: Sat, 14 Sep 2024 23:13:21 +0530 Subject: [PATCH] Handling client.logout() Exception gracefully with optional chaining (#2447) * Added Optional Chaining to Avoid Breaking The Code * Added Optional Chaining to Avoid Breaking Code * Updated code to handle all node version --------- Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com> Co-authored-by: Shir Serlui <70711723+shirser121@users.noreply.github.com> --- src/Client.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Client.js b/src/Client.js index 4825638..63f3153 100644 --- a/src/Client.js +++ b/src/Client.js @@ -802,7 +802,9 @@ class Client extends EventEmitter { */ async logout() { await this.pupPage.evaluate(() => { - return window.Store.AppState.logout(); + if (window.Store && window.Store.AppState && typeof window.Store.AppState.logout === 'function') { + return window.Store.AppState.logout(); + } }); await this.pupBrowser.close(); @@ -1723,4 +1725,4 @@ class Client extends EventEmitter { } } -module.exports = Client; +module.exports = Client; \ No newline at end of file