Skip to content

bug: WAWebChatLoadMessages.loadEarlierMsgs throws waitForChatLoading on undefined #201706

@JuniorRibas

Description

@JuniorRibas

Issue Priority

Medium (should be fixed soon)

Issue Description

Calling WAWebChatLoadMessages.loadEarlierMsgs in the WhatsApp Web context (for example, from DevTools with a valid chat object) results in:

Uncaught TypeError: Cannot read properties of undefined (reading "waitForChatLoading")

The stack trace points to the internal bundle (loadEarlierMsgs → access to waitForChatLoading on an undefined value). This affects the flow where the library used loadEarlierMsgs to paginate messages when fetching with limit in Chat / Channel.

There is a proposed fix/refactor that replaces this path with WAWebDBMessageFindLocal.msgFindBefore: see PR below.

Steps To Reproduce

  1. Open an authenticated WhatsApp Web session (same environment used by Puppeteer / whatsapp-web.js).
  2. In DevTools (Console), obtain a chat reference (for example via internal collections or a variable already exposed in your debug session).
  3. Run:
await window.require("WAWebChatLoadMessages").loadEarlierMsgs(chat);
  1. Observe the TypeError on waitForChatLoading.

Code Sample

// Minimal reproduction in WhatsApp Web console (with a valid `chat` in scope)
await window.require("WAWebChatLoadMessages").loadEarlierMsgs(chat);

WhatsApp Account Type

Standard

Authentication Strategy

LocalAuth

whatsapp-web.js Version

1.34.6

WhatsApp Web Version

(fill in with the output of await client.getWWebVersion() in your environment)

Browser Type

Chromium / Google Chrome

Browser Version

(exact browser version used in testing)

Computer OS Version

macOS (adjust if different)

Phone OS Version

(OS version of the phone linked to WhatsApp)

Node.js Version

(output of node -v in the project using the library)

Related Pull Request

Checklist

  • I use the latest released version of whatsapp-web.js.
  • I have searched existing issues and confirmed this is not a duplicate.
  • I have verified this is a library issue, not a problem with my code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions