diff --git a/src/Client.js b/src/Client.js index c673cef..51a6f25 100644 --- a/src/Client.js +++ b/src/Client.js @@ -702,7 +702,14 @@ class Client extends EventEmitter { await this.pupPage.evaluate(() => { return window.Store.AppState.logout(); }); - + await this.pupBrowser.close(); + + let maxDelay = 0; + while (this.pupBrowser.isConnected() && (maxDelay < 10)) { // waits a maximum of 1 second before calling the AuthStrategy + await new Promise(resolve => setTimeout(resolve, 100)); + maxDelay++; + } + await this.authStrategy.logout(); } diff --git a/src/authStrategies/LocalAuth.js b/src/authStrategies/LocalAuth.js index c66cfff..8309c3d 100644 --- a/src/authStrategies/LocalAuth.js +++ b/src/authStrategies/LocalAuth.js @@ -44,10 +44,10 @@ class LocalAuth extends BaseAuthStrategy { async logout() { if (this.userDataDir) { - return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true }); + return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true, force: true }); } } } -module.exports = LocalAuth; \ No newline at end of file +module.exports = LocalAuth;