fix: restore MsgKey._serialized on newer WA Web builds - #201901
netobasilio wants to merge 2 commits into
Conversation
|
Confirmed on WhatsApp Web 2.3000.1047868043 (whatsapp-web.js 1.34.7, puppeteer 24.38.0, Chrome, Node 22). Dumping the MsgKey of a just-sent message from the page shows the own properties are One suggestion: instead of fixing this single call site, defining a |
wa Web 2.3000.1043xxx+ no longer exposes `_serialized` on a MsgKey. The same value is still reachable through the minified `$1` property and through `toString()`, but the property itself is gone. `WWebJS.sendMessage` ends by looking the freshly created message up with `Msg.get(newMsgKey._serialized)`. On these builds that call becomes `Msg.get(undefined)` and returns nothing, so `Client.sendMessage` resolves to `undefined` even though the message was actually delivered. callers that check the return value treat a successful send as a failure, and no message id is available for tracking acks. fall back to `$1` and then to `toString()`, keeping `_serialized` first so older builds take exactly the same path as before.
Replace the single fallback in `WWebJS.sendMessage` with a `_serialized` getter on `WAWebMsgKey.prototype`, installed when the utils are loaded. The same missing property also breaks other page-side reads, such as `editMessage` (`Msg.get(msg.id._serialized)`) and `getChatModel` (`chat.lastReceivedKey._serialized`). A single getter fixes all of them. The getter is only installed when the prototype does not already define `_serialized`. Its setter stores an own property, so builds that still assign `_serialized` in the constructor behave exactly as before instead of failing on a getter-only accessor.
67a2721 to
1a94695
Compare
…_serialized No WhatsApp Web 2.3000.1043xxx+ a WAWebMsgKey não tem mais _serialized (a chave fica em $1/toString()), então o sendMessage fazia Msg.get(undefined) e resolvia undefined. - getter _serialized -> toString() no protótipo de WAWebMsgKey (baseado em wwebjs/whatsapp-web.js#201901, 1a94695), com try/catch - getMessageModel copia id._serialized para o Node (cf. #201840) - patch-package no postinstall com --error-on-fail --error-on-warn - whatsapp-web.js fixado em 1.34.7 - Dockerfile copia patches/ antes do npm ci Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Description
On WA Web
2.3000.1043xxx+aMsgKeyno longer exposes_serialized. The value isstill there, reachable through the minified
$1property and throughtoString(),but the named property is gone.
Every page-side read of
key._serializedthen returnsundefined. The most visible oneis the end of
WWebJS.sendMessage:This becomes
Msg.get(undefined), soClient.sendMessageresolves toundefinedeven though the message was actually delivered. Callers that check the return value
report a successful send as a failure, and there is no message id to track acks with.
The same pattern breaks
editMessage(Msg.get(msg.id._serialized)) and thelastMessagelookup ingetChatModel(chat.lastReceivedKey._serialized).This PR adds a
_serializedgetter toWAWebMsgKey.prototypewhenLoadUtilsruns.The getter returns
toString(), so all of these reads work again with a single changeinstead of one fallback per call site.
Compatibility with older builds:
_serialized.Re-injection is a no-op.
_serializedin theMsgKeyconstructor, the assignment works as before and the ownproperty shadows the getter. A getter-only accessor would make that assignment throw
in strict-mode code.
Updated after review: the first version only patched the
sendMessagecall site. Theprototype getter was suggested in the comments and covers every page-side read at once.
Relationship to #201840
#201840 covers the node-side model (
getMessageModel,getChatModel,Message._patch,downloadMedia). This PR does not replace it. A prototype getter isinherited, not own, so it is not copied when the page builds the plain model it sends
to Node. With this PR alone,
sendMessagereturns theMessageagain, but itsnode-side
id._serializedcan still beundefined.normalizeSerializedin #201840fixes that part. The two changes are complementary and do not overlap.
Related Issue(s)
Related to #201836 (
sendMessagereturning an empty message id) and #201862.I have deliberately not used a closing keyword: those reports do not state the WA Web
build precisely enough for me to confirm they are the same root cause.
Testing Summary
Test Details
patches): before,
sendMessage returned UNDEFINED; after,sendMessage returned Message. The message was delivered in both runs.production on 2.3000.1046520132 since early September, applied from the application
side. A reviewer independently reports the same shape fixing
sendMessage,editMessageandlastReceivedKeyon 2.3000.1047868043.MsgKeyclasses covering the threeshapes: new build (no
_serialized, value viatoString()), old build assigning anown
_serializedin a strict-mode constructor (value, descriptor andJSON.stringifyunchanged; re-assignment still works), and a prototype that already defines the
property (left untouched).
LoadUtilswas run twice to check idempotency. I have notre-run this exact patch against a live session.
npm run check: ESLint clean. Prettier reports only the pre-existing warning onindex.d.ts, which is also present on unmodifiedmain.npm testcould not be run: the suite requiresWWEBJS_TEST_REMOTE_IDand a dedicatedpaired account.
Environment
main@ 942d236)Type of Change
Checklist
npm test). See Test Details: the suite needs adedicated paired test account;
npm run checkpasses.index.d.ts) have been updated if necessary. No typing change.example.js) / documentation have been updated if applicable.Not applicable.