whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

App crashes when using the resetState() method.

Open gentil-eilison opened this issue 2 years ago • 1 comments

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

  1. Install whatsapp-web.js
  2. 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

gentil-eilison avatar Jul 08 '22 17:07 gentil-eilison

Use :-

client.destroy() client.initialize()

smilingOrange avatar Jul 29 '22 18:07 smilingOrange