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.21k stars 3.63k forks source link

Error when user disconnect on APP #1179

Closed guicuton closed 2 years ago

guicuton commented 2 years ago

Bug description

Since the last update when the user quit of paired session the client crashes

Reproduction steps

Steps to reproduce the behavior:

  1. Sync on main branch with a non-md account
  2. After ready, logout directly on app

Expected behavior

Close client without exception and destroy client (browser) but the browser still open and get back to qrcode scan area ref. PR #1169

Relevant code

(node:19712) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'AppState')
    at __puppeteer_evaluation_script__:2:33
    at ExecutionContext._evaluateInternal (C:\wamp64\www\whatsapp-api\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async ExecutionContext.evaluate (C:\wamp64\www\whatsapp-api\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async Client.getState (C:\wamp64\www\whatsapp-api\node_modules\whatsapp-web.js\src\Client.js:729:16)
    at async C:\wamp64\www\whatsapp-api\node_modules\whatsapp-web.js\src\Client.js:454:30

(Use `node --trace-warnings ...` to show where the warning was created)
(node:19712) 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 pr
omise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:19712) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Environment (please complete the following information):

WhatsApp

Library

Other

pedroslopez commented 2 years ago

I think I saw this once while working on something else, but wasn't able to reproduce it so I let it be. Again now trying to reproduce, I couldn't :/

However, this got me thinking about how we're detecting the logout and why WhatsApp Web was infinitely redirecting and I implemented a fix here #1181. Please let me know if that fixes your issue.

bmmangukiya commented 1 year ago

APP's still crashing on logging out sometime.