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

fix: Change resetState evaluate function in Client.js #3358

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gusfahmi
Copy link

PR Details

The PR fixes an issue where the client.resetState() function throws an error:

Evaluation failed: TypeError: Cannot read properties of undefined (reading 'shiftTimer')
at pptr://puppeteer_evaluation_script:2:49

Description

After digging to window.Store in WhatsApp web, i found out that window.Store.AppState.phoneWatchdog.shiftTimer.forceRunNow(); is no longer available, it changed to window.Store.AppState.reconnect();
it will force WhatsApp state to reconnect every time it loses connection.

Related Issue(s)

#3246 #2283

How Has This Been Tested

client.on('change_state', async () => {
    await client.resetState()
});

##You can try the fix by running one of the following commands:
NPM
npm install https://github.com/gusfahmi/whatsapp-web.js.git#fix/resetState

Environment

  • Machine OS: Windows
  • Phone OS: IOS & Android
  • Library Version: v1.26.0
  • Browser Type and Version: Google Chrome
  • Node Version: v20.11.0

Types of changes

  • Dependency change
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • I have updated the documentation accordingly (index.d.ts).
  • I have updated the usage example accordingly (example.js)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants