Skip to content

Commit 8d5a60f

Browse files
author
Alessandro Borile
committed
catch context close if framenavigated
1 parent c018e2d commit 8d5a60f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Client.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ class Client extends EventEmitter {
9393
* Private function
9494
*/
9595
async inject() {
96+
let hasReloaded = false;
97+
const reloadHandler = async () => {
98+
hasReloaded = true;
99+
};
100+
try{
101+
this.pupPage.on('framenavigated', reloadHandler);
102+
96103
await this.pupPage.waitForFunction('window.Debug?.VERSION != undefined', {timeout: this.options.authTimeoutMs});
97104

98105
const version = await this.getWWebVersion();
@@ -255,6 +262,13 @@ class Client extends EventEmitter {
255262
await window.onLogoutEvent();
256263
});
257264
});
265+
266+
}catch(err){
267+
if(!hasReloaded)
268+
throw err;
269+
}finally{
270+
this.pupPage.off('framenavigated', reloadHandler);
271+
}
258272
}
259273

260274
/**

0 commit comments

Comments
 (0)