Skip to content

Commit 573e7e8

Browse files
committed
fix: remove unnecessary try/catch blocks in framenavigated handler
- storeAvailable: evaluate() always succeeds after framenavigated because Puppeteer waits for the execution context automatically (verified via CDP event order and Puppeteer source) - inject(): matches upstream behavior - let errors surface instead of silently swallowing them
1 parent 0830daa commit 573e7e8

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/Client.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,15 @@ class Client extends EventEmitter {
294294
},
295295
);
296296

297+
this._hasSyncedTriggered = false;
298+
297299
await exposeFunctionIfAbsent(
298300
this.pupPage,
299301
'onAppStateHasSyncedEvent',
300302
async () => {
303+
if (this._hasSyncedTriggered) return;
304+
this._hasSyncedTriggered = true;
305+
301306
const authEventPayload =
302307
await this.authStrategy.getAuthEventPayload();
303308
/**
@@ -547,22 +552,13 @@ class Client extends EventEmitter {
547552
this.lastLoggedOut = false;
548553
}
549554

550-
let storeAvailable = false;
551-
try {
552-
storeAvailable = await this.pupPage.evaluate(() => {
553-
return typeof window.WWebJS !== 'undefined';
554-
});
555-
} catch (e) {
556-
/* page may not be ready */
557-
}
555+
const storeAvailable = await this.pupPage.evaluate(() => {
556+
return typeof window.WWebJS !== 'undefined';
557+
});
558558

559559
if (!isLogout && storeAvailable) return;
560560

561-
try {
562-
await this.inject();
563-
} catch (err) {
564-
// inject() may fail if page is still loading after navigation
565-
}
561+
await this.inject();
566562
});
567563
}
568564

0 commit comments

Comments
 (0)