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>
This commit is contained in:
Ayush Mourya 2024-09-14 23:13:21 +05:30 • committed by GitHub
commit 22af9df3d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -802,7 +802,9 @@ class Client extends EventEmitter {
*/ */
async logout() { async logout() {
await this.pupPage.evaluate(() => { await this.pupPage.evaluate(() => {
if (window.Store && window.Store.AppState && typeof window.Store.AppState.logout === 'function') {
return window.Store.AppState.logout(); return window.Store.AppState.logout();
}
}); });
await this.pupBrowser.close(); await this.pupBrowser.close();