Skip to content

Commit

Permalink
馃毟 Invariant violation avoidance measures #3121
Browse files Browse the repository at this point in the history
  • Loading branch information
smashah committed May 15, 2023
1 parent ba5ba19 commit ef2dcff
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/controllers/initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ export async function create(config: AdvancedConfig | ConfigObject = {}): Promis
// eslint-disable-next-line @typescript-eslint/no-unused-vars
spinner.succeed('Use this easy pre-filled link to report an issue: ' + generateGHIssueLink(config,debugInfo));
spinner.info(`Time to injection: ${(now() - browserLaunchedTs).toFixed(0) }ms`);
/**
* Atempt to avoid invariant violations
*/
const invariantAviodanceTs = now();
await Promise.race([
(waPage as Page).waitForFunction(`(()=>{if(!window.webpackChunkwhatsapp_web_client && window.webpackChunkwhatsapp_web_client.length) return false; return window.webpackChunkwhatsapp_web_client.length > 15})()`, {timeout: 10000}).catch(()=>{}), //modules are loaded
(waPage as Page).waitForFunction(`[...document.getElementsByTagName('div')].filter(x=>x.dataset && x.dataset.testid)[0]?.dataset?.testid === 'qrcode'`, {timeout: 10000}).catch(()=>{}), //qr code is loaded
(waPage as Page).waitForFunction(`document.getElementsByTagName('circle').length===1`, {timeout: 10000}).catch(()=>{}) //qr spinner is present
])
spinner.info(`Invariant Violation Avoidance: ${(now() - invariantAviodanceTs).toFixed(0) }ms`);
if (canInjectEarly) {
if(attemptingReauth) await waPage.evaluate(`window.Store = {"Msg": true}`)
spinner.start('Injecting api');
Expand Down

0 comments on commit ef2dcff

Please sign in to comment.