whatsapp-web.js
whatsapp-web.js copied to clipboard
App crashes when using the resetState() method.
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
Right after the "ready" event is triggered, I call resetState and the program crashes, closing the browser.
Expected behavior
The expected behavior is for the client to reset the connection state and don't close.
Steps to Reproduce the Bug or Issue
- Install whatsapp-web.js
- Call resetState inside the "ready" event callback
Relevant Code
const { Client, LocalAuth } = require("whatsapp-web.js");
const sleep = async (time) => new Promise(resolve => setTimeout(resolve, time))
const client = new Client({
authStrategy: new LocalAuth(),
puppeteer: {
headless: false
}
});
client.initialize();
client.on("ready", async () => {
await sleep(3000);
await client.resetState();
console.log("Resetei")
});
Browser Type
Chromium
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
- OS: Windows 10
- Phone OS: Android
- whatsapp-web.js version: 1.17.0
- WhatsApp Web version: 2.2224.8
- Node.js Version: 16.14.2
Additional context
No response
Use :-
client.destroy() client.initialize()