Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client.resetState() error caused by shiftTimer #3246

Open
1 task done
gusfahmi opened this issue Aug 19, 2024 · 1 comment
Open
1 task done

Client.resetState() error caused by shiftTimer #3246

gusfahmi opened this issue Aug 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@gusfahmi
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

i used LocalAuth as client initialize, after i scan the qr, and wait for a few minute, the client is destroy.
i tried to add change_state and the state said OPENING, after a few seconds, it throws an error said
Evaluation failed: TypeError: Cannot read properties of undefined (reading 'shiftTimer')
at pptr://puppeteer_evaluation_script:2:49

i used this solution #2283 but it's not working.

Expected behavior

i expected it can reset the client state back to online rather than throw an error caused by shiftTimer

Steps to Reproduce the Bug or Issue

  1. use LocalAuth for authentication
  2. add change_state event in client
  3. wait for a few minutes
  4. the client is destroyed

Relevant Code

client.on('change_state', async (_state) => {

			let state = _state 
			
			try{
			
				const number = client.info.wid.user
 
				console.log(`Client ${number} state : ${state}`)
				/** 
				 * Once the internet connection is lost the client state will be set to WAState.OPENING.
				 * The resetState function immediately changes the client state to WAState.CONNECTED
				 * after internet reconnection.
				 */

				while (state === WAState.OPENING || state === WAState.TIMEOUT || state === WAState.UNPAIRED) {
					await client.resetState();
					
					/** 
					 * It is recommended to add a delay after each iteration at least 1000 msec
					 * to prevent useless frequent function calls and unexpected behavior.
					 */
					await delay(3000);
				}
 
				console.log(`Client ${number} state : ${state} after change`) 

			}catch(e){

				console.log(e.message) 
			}
		
		});

Browser Type

Google Chrome

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Linux (Ubuntu : 20.04.6)
Phone : IOS
Whatsapp-web.js version : 1.25.0
Node.js version : 20.11.0

Additional context

No response

@gusfahmi gusfahmi added the bug Something isn't working label Aug 19, 2024
@Nurse1angeL
Copy link

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants