diff --git a/src/conn/events/registerMainReadyEvent.ts b/src/conn/events/registerMainReadyEvent.ts index 476e3e6326..3fce1b5dae 100644 --- a/src/conn/events/registerMainReadyEvent.ts +++ b/src/conn/events/registerMainReadyEvent.ts @@ -26,9 +26,7 @@ loader.onInjected(register); function register() { const isReadyMode = (mode: StreamMode) => - mode === StreamMode.MAIN || - mode === StreamMode.QR || - mode === StreamMode.SYNCING; + mode === StreamMode.MAIN || mode === StreamMode.QR; const checkMode = (mode: StreamMode) => { if (isReadyMode(mode)) { diff --git a/src/tools/browser.ts b/src/tools/browser.ts index c1d57c3a18..16f4f3e442 100644 --- a/src/tools/browser.ts +++ b/src/tools/browser.ts @@ -292,25 +292,38 @@ export async function getPage(options?: LaunchArguments[1]) { await preparePage(page); setTimeout(async () => { + console.log('⏳ Waiting for WhatsApp Web to load...'); await page.goto(URL, { waitUntil: 'domcontentloaded', timeout: 120000, }); + console.log( + '✅ WhatsApp Web loaded, waiting for main stream to be ready...' + ); await page .waitForFunction( () => (window as any).Debug?.VERSION, {}, { timeout: 120000 } ) - .catch(() => null); + .catch(() => { + console.warn( + '⚠️ Timeout waiting for Debug.VERSION, main stream might not be ready' + ); + }); const version = await page .evaluate(() => (window as any).Debug.VERSION) - .catch(() => null); + .catch(() => { + console.warn( + '⚠️ Failed to get Debug.VERSION, main stream might not be ready' + ); + return 'unknown'; + }); console.log('WhatsApp Version: ', version); - }, 1000); + }, 2000); return { browser, page }; }