fix(structures): use updated loadEarlierMsgs options signature in fetchMessages#201713
Merged
BenyFilho merged 1 commit intowwebjs:mainfrom Apr 13, 2026
Merged
Conversation
WhatsApp Web changed the signature of WAWebChatLoadMessages.loadEarlierMsgs
from positional (chat, msgCollection) to an options object
{chat, msgCollection, signal, threadId, trigger}.
Calling the old positional form crashes with "Cannot read properties of
undefined (reading 'waitForChatLoading')" because the destructure reads
e.chat on the first positional argument instead of treating the first
argument as the chat.
Updates both Chat.fetchMessages and Channel.fetchMessages to pass the
options object. No other behaviour change.
9 tasks
BenyFilho
approved these changes
Apr 13, 2026
This was referenced Apr 13, 2026
tuyuribr
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WhatsApp Web changed the signature of
WAWebChatLoadMessages.loadEarlierMsgsfrom positional(chat, msgCollection)to an options object{ chat, msgCollection, signal, threadId, trigger }.Calling the old positional form crashes with
Cannot read properties of undefined (reading 'waitForChatLoading')because the destructure readse.chaton the first positional argument instead of treating the first argument as the chat.Updates both
Chat.fetchMessagesandChannel.fetchMessagesto pass the options object. No other behaviour change.msgCollectionis intentionally omitted — theloadEarlierMsgsimplementation already falls back tochat.msgswhen it is not provided, so passing it explicitly would be redundant.Related Issue(s)
Fixes #201706
Testing Summary
Test Details
chat.fetchMessages({ limit: 100 })crashed inside the injectedloadEarlierMsgscall withCannot read properties of undefined (reading 'waitForChatLoading')as soon as the loop attempted to page earlier messages.chat.fetchMessages({ limit: 100 })returns without error and paginates backwards vialoadEarlierMsgsuntil the requested limit is reached or WhatsApp Web reports no earlier messages available.channel.fetchMessages({ limit: 50 })on a newsletter/channel returns the same corrected behaviour — no crash, correct pagination.Environment
Type of Change
Checklist
npm test).index.d.ts) have been updated if necessary. (no public API change — the method signature offetchMessagesis unchanged, only its internal call to a WA Web module was corrected)example.js) / documentation have been updated if applicable. (no API surface change)