Skip to content

fix: dual-compat for WA Web 2.3000.1043xxx ($1 vs _serialized, downloadMedia)#201840

Open
erickmourasilva wants to merge 1 commit into
wwebjs:mainfrom
erickmourasilva:fix/wa-web-1043-serialized-compat-pr
Open

fix: dual-compat for WA Web 2.3000.1043xxx ($1 vs _serialized, downloadMedia)#201840
erickmourasilva wants to merge 1 commit into
wwebjs:mainfrom
erickmourasilva:fix/wa-web-1043-serialized-compat-pr

Conversation

@erickmourasilva

Copy link
Copy Markdown

Summary

  • Add widSerialized() / normalizeSerialized() so WID/MsgKey work with both _serialized (legacy) and $1 (WA Web 2.3000.1043xxx+).
  • Wire helpers into getMessageModel and getChatModel (fixes getChatById / typing crashes with r: r).
  • Dual-read LID/PN in getContactLidAndPhone and Message _patch from/to/author.
  • Use dual message id for downloadMedia / downloadMediaStream.
  • In resolveMediaBlob, fall back to DownloadManager.downloadAndMaybeDecrypt when the in-memory blob is missing or looks thumbnail-sized vs msg.size.

Compatibility

  • Old WA Web: unchanged path via _serialized.
  • New WA Web: falls back to $1 and mirrors onto _serialized for node-side consumers.

Test plan

  • Text receive + send on WA Web before 2.3000.1043xxx
  • Text receive + send on WA Web 2.3000.1043xxx+
  • msg.getChat() / typing indicator does not throw
  • Incoming image: downloadMedia() returns full media (bytes ≈ msg.size, not thumbnail)
  • getContactLidAndPhone still returns lid/pn strings

Closes #201831

Made with Cursor

Keep `_serialized` working for older WhatsApp Web clients and accept
`$1` on newer builds. Normalize models returned to Node, dual-read
LID/PN and message ids, and fall back to DownloadManager when the
in-memory media blob looks incomplete/thumbnail-sized.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added api changes API modifications utility Utility code labels Jul 15, 2026
@kulayRGB

Copy link
Copy Markdown

just heads up that _serialized to $1 rename is causing also msg.react() and msg.reply to fail silently. Adding react and reply fallback in Message.js fixes the issue. These fixes works for me

in async react(reaction)
-- from return this.client.sendReaction(this.id._serialized, reaction); --> to return this.client.sendReaction(this.id._serialized || this.id.$1, reaction);

in async reply()
-- from quotedMessageId: this.id._serialized, --> to quotedMessageId: this.id._serialized || this.id.$1

Lewson added a commit to Lewson/whatsapp-web.js that referenced this pull request Jul 18, 2026
…0.1043xxx)

Adapted from wwebjs upstream PR wwebjs#201840. Fixes media download failing
with opaque 'r: r' error after WhatsApp Web renamed id._serialized to
$1 and started returning thumbnails from mediaBlob.forceToBlob() in
version 2.3000.1043xxx (Jul-2026).

- Utils.js resolveMediaBlob: null-safe cache lookup + forceToBlob guard,
  plus fallback via WAWebDownloadManager.downloadAndMaybeDecrypt when
  the blob cache is empty or looks like a thumbnail.
- Message.js downloadMedia / downloadMediaStream: extract msgId with
  `this.id._serialized ?? this.id.$1` before passing to evaluate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api changes API modifications utility Utility code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error con pupeter

3 participants