whatsapp-web.js
whatsapp-web.js copied to clipboard
Exception when client disconnects
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
If the client removes the connection from Linked devices (on the phone) I get this exception:
/var/www/wa/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:230
error: new Errors_js_1.ProtocolError(),
^
ProtocolError: Protocol error (Runtime.callFunctionOn): Target closed.
at /var/www/wa/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:230:24
at new Promise (<anonymous>)
at CDPSession.send (/var/www/wa/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:226:16)
at ExecutionContext._evaluateInternal (/var/www/wa/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:204:50)
at ExecutionContext.evaluateHandle (/var/www/wa/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:155:21)
at WaitTask.rerun (/var/www/wa/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:551:37)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
originalMessage: ''
}
Also, this exception appears in I'm trying to disconnect the client with Client.destroy() Just so you know, this exception appears from time to time.
Expected behavior
Disconnect without exception.
Steps to Reproduce the Bug or Issue
- Connect with your device
- Disconnect the device (with WhatsApp settings)
Relevant Code
No response
Browser Type
Chromium
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
- Ubuntu 18.04
- iOS
- whatsapp-web.js version 1.21.0
- WhatsApp Web version 2.2326.10
- Node.js version 16.13.1
Additional context
I'm using LocalAuth. Client created like this
waClient = new Client({
puppeteer: {
args: ['--no-sandbox'],
},
authStrategy: new LocalAuth({
clientId: this.id
})
});
global.client.on('disconnected', (reason) => { // destroy session here // re init client });
// before any action : you must test if session existe
I'm get same error this error it come when return loading screen or "whatsapp" word by Arabic language, I check on return it close and reruning and I change language of the Whatsapp to EN and get the last version update of whatsapp app
global.client.on('disconnected', (reason) => { // destroy session here // re init client });
// before any action : you must test if session existe
I got
this.client.on('disconnected', () => {
this.client.destroy();
});
but it doesn't work. I'm getting exception anyway. I'm not trying to do anything on a closed session. I got this exception immediately when click disconnect on my phone.