[WEBJS] - waha is not reciven message events
[W] Error r: r at #evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:391:56) at async ExecutionContext.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:277:16) at async IsolatedWorld.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:100:16) at async CdpFrame.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:362:20) at async CdpPage.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:818:20) at async WPage.evaluate (/app/dist/core/engines/webjs/WPage.js:13:20) at async WebjsClientCore.getChatById (/app/node_modules/whatsapp-web.js/src/Client.js:1780:22) at async /app/node_modules/whatsapp-web.js/src/Client.js:869:30 at async Binding.run (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Binding.js:132:32) at async #onBindingCalled (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Page.js:655:9) "version": "YYYY.MM.DD", "engine": "ENGINE", "tier": "TIER" }
Try to update to
[the latest version](https://github.com/devlikeapro/waha/releases) before
creating an issue!
## Steps
**To Reproduce** Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
### Expected behavior
A clear and concise description of what you expected to happen.
### Requests - Responses
Please attach all sent requests, responses that you sent.
### Docker Logs
Collect and attach related docker logs if you have any
https://waha.devlike.pro/docs/how-to/deploy/#viewing-the-logs
### Screenshots
If applicable, add screenshots to help explain your problem.
### Additional context
Add any other context about the problem here.
For WPP engine, we are also getting this error. Just try to send a message using ChatUI from Dashboard.
[18:06:09.259] INFO (7): request errored {"reqId":784,"req":{"id":784,"method":"POST","url":"/api/sendText","query":{},"params":{"path":["api","sendText"]}},"res":{"statusCode":500},"responseTime":209}
err: {
"type": "Error",
"message": "The key argument has to be of type string or number. Found: object",
"stack":
EKEYTYPE: The key argument has to be of type string or number. Found: object
at NodeCache._error (/app/node_modules/node-cache/lib/node_cache.js:762:17)
at NodeCache._isInvalidKey (/app/node_modules/node-cache/lib/node_cache.js:668:23)
at NodeCache.set (/app/node_modules/node-cache/lib/node_cache.js:424:25)
at WhatsappSessionWPPCore.saveSentMessageId (/app/dist/core/abc/session.abc.js:652:29)
at WhatsappSessionWPPCore.sendText (/app/dist/core/engines/wpp/session.wpp.core.js:608:14)
at async descriptor.value (/app/dist/core/abc/activity.js:9:20)
"name": "EKEYTYPE",
"errorcode": "EKEYTYPE",
"data": {
"type": "object"
}
}
Message is Sent, but API returns error 500
Using monitor, we can see that Id now its an object, just like pointed on error message:
We need just a fix on https://github.com/devlikeapro/waha/blob/208f4f3d78b15f68d9b17e78f5318c0e2ceb26de/src/core/engines/wpp/session.wpp.core.ts#L597 getting id from object
+1
As this is typescript project I asked Claude to fix the bug inside the docker container itself, then restart. It will work until you remove the docker container.
Do not treat this as a permanent solutions. It's just to get it working again temporarily
Root cause #1 — MessageId._serialized is now undefined
WhatsApp moved the serialized message-key string off _serialized onto a minified property. JSON.stringify(message.id) on an inbound message now looks like:
{ "fromMe": false, "remote": "4712...@lid", "id": "3EB0...", "$1": "false_4712...@lid_3EB0..." }
So message.id._serialized is undefined, and:
toWAMessage()→parseMessageIdSerialized(undefined)→TypeError: Cannot read properties of undefined (reading 'includes')→ every inboundmessageevent is dropped.Message.downloadMedia()→resolveMediaBlob(this.id._serialized)→getMessagesById([undefined])→r→ all inbound media fails (MediaManager: Failed to execute 'Fetching media').
Fix: rebuild the canonical fromMe_remote_id[_participant] string from the id fields (byte-identical to the new $1).
src/core/utils/ids.ts
export function parseMessageIdSerialized(
messageId: string,
soft: boolean = false,
): WAMessageKey {
+ // WhatsApp Web moved MsgKey._serialized to a minified field; callers can now
+ // receive undefined. Fail soft instead of throwing on `.includes`.
+ if (messageId == null) {
+ return { id: messageId };
+ }
if (!messageId.includes('_') && soft) {
return { id: messageId };
}
@@ export function SerializeMessageKey(key: WAMessageKey) {
const participantStr = participant ? `_${participant}` : '';
return `${fromMe ? 'true' : 'false'}_${remoteJid}_${id}${participantStr}`;
}
+
+/**
+ * whatsapp-web.js no longer receives `MessageId._serialized` from WhatsApp Web
+ * (the value moved to a minified field). Rebuild the canonical serialized id
+ * from the MessageId object. Returns `_serialized` unchanged when present.
+ */
+export function SerializeWebJSMessageId(id: any): string | undefined {
+ if (!id) return undefined;
+ if (id._serialized) return id._serialized;
+ const remote = (id.remote && id.remote._serialized) || id.remote;
+ if (remote == null || id.id == null) return id._serialized;
+ const participant = id.participant
+ ? `_${id.participant._serialized || id.participant}`
+ : '';
+ return `${id.fromMe ? 'true' : 'false'}_${remote}_${id.id}${participant}`;
+}
src/core/engines/webjs/session.webjs.core.ts
import {
parseMessageIdSerialized,
SerializeMessageKey,
+ SerializeWebJSMessageId,
} from '@waha/core/utils/ids';
protected toWAMessage(message: Message): WAMessage {
const replyTo = this.extractReplyTo(message);
const source = this.getMessageSource(message.id.id);
- const key = parseMessageIdSerialized(message.id._serialized);
+ const idSerialized =
+ SerializeWebJSMessageId(message.id) ?? message.id._serialized;
+ const key = parseMessageIdSerialized(idSerialized);
// @ts-ignore
return {
- id: message.id._serialized,
+ id: idSerialized,
timestamp: message.timestamp,
protected async downloadMedia(message: Message) {
+ // downloadMedia() -> resolveMediaBlob(this.id._serialized) breaks when
+ // _serialized is undefined; populate it so media (and quoted media) resolve.
+ if (message?.id && !message.id._serialized) {
+ message.id._serialized = SerializeWebJSMessageId(message.id);
+ }
let processor = new WEBJSEngineMediaProcessor();
processor = new LottieMediaProcessorWrapper(processor, this.logger);
const media = await this.mediaManager.processMedia(
processor,
message,
this.name,
);
return media;
}
Root cause #2 — getChatById() full chat-model serialization throws r
getChatById() → getChat(chatId, { getAsModel: true }) → getChatModel() now throws a minified r inside WhatsApp's bundle. This 500s startTyping / stopTyping / sendSeen / readChatMessages, even though those only need the chat id — not the serialized model. The lighter primitives (Client.sendSeen() uses getAsModel: false; presence goes straight through WWebJS.sendChatstate) are unaffected.
src/core/engines/webjs/session.webjs.core.ts
async sendSeen(request: SendSeenRequest) {
- const chat: Chat = await this.whatsapp.getChatById(
- this.ensureSuffix(request.chatId),
- );
- await chat.sendSeen();
+ // Client.sendSeen -> getChat(chatId, { getAsModel: false }) skips the
+ // (currently broken) getChatModel serialization.
+ await this.whatsapp.sendSeen(this.ensureSuffix(request.chatId));
}
@Activity()
async startTyping(request: ChatRequest): Promise<void> {
- const chat: Chat = await this.whatsapp.getChatById(
- this.ensureSuffix(request.chatId),
- );
- await chat.sendStateTyping();
+ const chatId = this.ensureSuffix(request.chatId);
+ await this.whatsapp.pupPage.evaluate(
+ (chatId) => window.WWebJS.sendChatstate('typing', chatId),
+ chatId,
+ );
}
@Activity()
async stopTyping(request: ChatRequest) {
- const chat: Chat = await this.whatsapp.getChatById(
- this.ensureSuffix(request.chatId),
- );
- await chat.clearState();
+ const chatId = this.ensureSuffix(request.chatId);
+ await this.whatsapp.pupPage.evaluate(
+ (chatId) => window.WWebJS.sendChatstate('stop', chatId),
+ chatId,
+ );
}
readChatMessages has the same throwaway getChatById and can use await this.whatsapp.sendSeen(...) too; getChatMessages uses getChatById only to warm the Store, so wrapping it in getChat(chatId, { getAsModel: false }) (or a try/catch) keeps history fetches from 500ing.
Environment: devlikeapro/waha:latest-2026.6.2, WEBJS engine, whatsapp-web.js 1.34.7, Chromium 143.
2026.7.1 - WEBJS - waha is not receiving message events after the _serialized id rename - #2157, #2162