Improve logout() LocalAuth logic (#2175)
* Improve logout() LocalAuth logic - Wait for browser to close to prevent Exception on Windows * Update Client.js * Update LocalAuth.js --------- Co-authored-by: Rajeh Taher <rajeh@reforward.dev> Co-authored-by: tuyuribr <45042245+tuyuribr@users.noreply.github.com> Co-authored-by: Shir Serlui <70711723+shirser121@users.noreply.github.com>
This commit is contained in:
parent
d272389246
commit
776c1b152e
2 changed files with 10 additions and 3 deletions
|
|
@ -702,7 +702,14 @@ class Client extends EventEmitter {
|
||||||
await this.pupPage.evaluate(() => {
|
await this.pupPage.evaluate(() => {
|
||||||
return window.Store.AppState.logout();
|
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();
|
await this.authStrategy.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ class LocalAuth extends BaseAuthStrategy {
|
||||||
|
|
||||||
async logout() {
|
async logout() {
|
||||||
if (this.userDataDir) {
|
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;
|
module.exports = LocalAuth;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue