Skip to content

fix(client): use timer polling for authentication readiness - #201942

Open
kondv wants to merge 1 commit into
wwebjs:mainfrom
kondv:kondv-whatsapp-polling-pr
Open

kondv wants to merge 1 commit into
wwebjs:mainfrom
kondv:kondv-whatsapp-polling-pr

Conversation

@kondv

@kondv kondv commented Sep 29, 2026

Copy link
Copy Markdown

Description

Use explicit 200 ms interval polling for the Debug.VERSION and socket-state waits in Client.inject(). Both predicates describe application state, not rendering, but Puppeteer's default polling depends on animation callbacks.

When animation callbacks stop and timers continue, initialization currently times out even after those values become ready. This change keeps the existing predicates, timeouts, and abort behavior while allowing the waits to observe readiness without rendering.

Add account-free Chromium tests that exercise actual Client initialization using offline fixtures, plus instructions for running them independently of the authenticated integration suite. No dependency, public API/type, or navigation changes.

Head: kondv:kondv-whatsapp-polling-pr at 358051d12b76aa4d5544a2fbc86ebf3f93d11358.

Related Issue(s)

Fixes #201940

Follow-up to #201653's waitForFunction conversion, not a resubmission of that merged fix. This does not duplicate #201853's post-authentication Stream changes or #201893's navigation handling. Navigation and browser-cleanup changes are not included.

Testing Summary

Test Details

The same new regression file was run against upstream and the polling patch. The publication commit was rerun after committing:

Revision Result
Upstream 064a3d5a5a3dce1281a6a12740b5a7051339d154 6 passing, 2 failing: delayed Debug and socket readiness
This PR, 358051d12b76aa4d5544a2fbc86ebf3f93d11358 8 passing (16s)

Command:

NODE_OPTIONS=--unhandled-rejections=strict npm run test-single -- tests/client-auth-polling.js

An existing Chromium executable was selected with PUPPETEER_EXECUTABLE_PATH.

The fixtures suppress animation callbacks and make readiness arrive after the first predicate check. Both delayed cases now emit one synthetic QR without false authentication or ready events. Controls cover immediate readiness, unchanged timeouts, initial-wait cancellation on destroy, authentication-strategy errors, and an already-connected socket. Each test closes its dedicated browser and checks temporary-profile removal and the absence of browser script errors.

Node syntax checks, targeted ESLint, Prettier, git diff --check, and commitlint pass. Commitlint reported 0 problems and 0 warnings before committing and for the committed message.

The full npm test suite was not run because it requires an authenticated account and sends real messages. There is no separate build script.

These account-free tests establish the failure mechanism, not how often rendering pauses occur in normal browser operation or production stability. Timer polling can still be throttled or suspended; this is not a guarantee of progress during arbitrary suspension.

Environment

  • Machine OS: macOS 26.6.2
  • Phone OS: N/A; no phone used
  • Library Version: current main at 064a3d5a5a3dce1281a6a12740b5a7051339d154 plus this patch (package version 1.34.7)
  • WhatsApp Web Version: N/A; synthetic offline fixture
  • Browser Type and Version: Google Chrome for Testing 149.0.7827.55, Puppeteer 24.38.0
  • Node Version: 22.20.0

Type of Change

  • Dependency change (package changes such as removals, upgrades, or additions)
  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-code change (documentation, README, etc.)

Checklist

  • My code follows the style guidelines of this project.
  • All new and existing tests pass (npm test).
  • Typings (e.g. index.d.ts) have been updated if necessary.
  • Usage examples (e.g. example.js) / documentation have been updated if applicable.

The focused offline suite passes; the authenticated suite was not run. No public type change is needed. tests/README.md documents the account-free test command.

Poll the nonvisual Debug and socket readiness predicates every 200ms
while preserving their existing timeouts and cancellation behavior.
Add account-free Chromium regressions and test instructions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added docs Documentation changes api changes API modifications tests Test related labels Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api changes API modifications docs Documentation changes tests Test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authentication readiness times out when animation callbacks stop

1 participant