pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.07k stars 3.59k forks source link

Getting issue for whatsapp scan #663

Closed bhejosms closed 3 years ago

bhejosms commented 3 years ago

Some time when some one scan QR code it get scanned on phone it shows login but session.json file is not created as well as logs shows below exception

(node:12694) UnhandledPromiseRejectionWarning: TimeoutError: waiting for selector canvas failed: timeout 45000ms exceeded at new WaitTask (/home/cspl/Desktop/Whatsapp/WhatsappAPI/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:505:34) at DOMWorld.waitForSelectorInPage (/home/cspl/Desktop/Whatsapp/WhatsappAPI/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:416:26) at Object.internalHandler.waitFor (/home/cspl/Desktop/Whatsapp/WhatsappAPI/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:31:77) at DOMWorld.waitForSelector (/home/cspl/Desktop/Whatsapp/WhatsappAPI/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:312:29) at Frame.waitForSelector (/home/cspl/Desktop/Whatsapp/WhatsappAPI/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:842:51) at Page.waitForSelector (/home/cspl/Desktop/Whatsapp/WhatsappAPI/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1285:33) at Timeout.getQrCode [as _onTimeout] (/home/cspl/Desktop/Whatsapp/WhatsappAPI/node_modules/whatsapp-web.js/src/Client.js:128:28) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:12694) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 34)

PurpShell commented 3 years ago

const client = new Client({ qrTimeoutMs:0 });

guicuton commented 3 years ago

use .catch on initialize... this will supress this warning

eg:

    let whatsapp = new Client();
    whatsapp.initialize().catch((_) => _);
kunduarnab commented 3 years ago

const client = new Client({ qrTimeoutMs:0 });

This solves my problem. Thank you