waha icon indicating copy to clipboard operation
waha copied to clipboard

[WEBJS] - sendText returns 500: encryptMsgProtobuf "Cannot read properties of undefined (reading 'nextMsgIndex')" — encryption fails for the session's own @c.us

Open alvaromoura-nibo opened this issue 5 months ago • 1 comments

Describe the bug

POST /api/sendText returns HTTP 500. The underlying WhatsApp Web error is an encryption failure while building the outgoing message — and it fails for the session's own account JID (@c.us), not the recipient:

[messaging] encryptMsgProtobuf: encryption fail for <session-own-number>@c.us, Cannot read properties of undefined (reading 'nextMsgIndex')

Evidence that <session-own-number>@c.us is the sender (the QR-scanned account), not the recipient: the @c.us value is constant per session and independent of the recipient — the same session fails with the same @c.us while sending to many different chats. This looks like the self/own-identity fanout encryption: there is no Signal session record for the account's own @c.us at encrypt time (nextMsgIndex read off undefined). Possibly tied to the account's LID migration (the own identity moved to @lid, but a code path still encrypts for the legacy own @c.us).

WAHA bundles its own fork of whatsapp-web.js, so the Client.js:1064 sendMessage frame below is from that bundled fork (not upstream pedroslopez/whatsapp-web.js).

Version

{ "version": "2026.4.1", "engine": "WEBJS", "tier": "PLUS" }

(browser: google-chrome, platform: linux/x64)

Steps

To Reproduce

  1. WEBJS session in WORKING state.
  2. POST /api/sendText (recipients are addressed via @lid; linkPreview: true).
  3. Returns HTTP 500 with the error above; the message is not delivered.

Expected behavior

WAHA should encrypt/send successfully (re-establishing the own-account Signal session / handling the own-identity @c.us ↔ @lid mapping), or return a clear, retryable error instead of a raw Cannot read properties of undefined (reading 'nextMsgIndex').

Requests - Responses

Response — HTTP 500 (sanitized):

{
  "statusCode": 500,
  "exception": {
    "name": "Error",
    "message": "[messaging] encryptMsgProtobuf: encryption fail for <session-own-number>@c.us, Cannot read properties of undefined (reading 'nextMsgIndex')"
  },
  "request": { "path": "/api/sendText", "method": "POST" },
  "version": { "version": "2026.4.1", "engine": "WEBJS", "tier": "PLUS", "platform": "linux/x64" }
}

Docker Logs

Error: [messaging] encryptMsgProtobuf: encryption fail for <session-own-number>@c.us, Cannot read properties of undefined (reading 'nextMsgIndex')
    s (https://static.whatsapp.net/rsrc.php/v4/yk/r/<asset>.js:80:180)
    at async WPage.evaluate (/app/dist/core/engines/webjs/WPage.js:13:20)
    at async WebjsClientPlus.sendMessage (/app/node_modules/whatsapp-web.js/src/Client.js:1064:25)
    at async descriptor.value (/app/dist/core/abc/activity.js:9:20)

Additional context

  • The failing @c.us is the session's own number (QR-scanned account): constant per session, and does not vary with the recipient. Recipients happen to be addressed by @lid, but that is not the failing identity.
  • Reproduced across many sessions and recipients (~420 sendText 500s in 7 days on 2026.4.1, WEBJS).
  • Possibly related (different engine): #1376 (GOWS/NOWEB "no signal session established").

patron:PRO

alvaromoura-nibo avatar Jun 19 '26 15:06 alvaromoura-nibo

Same to me

patron:PRO

leonardolimafarias avatar Jun 19 '26 21:06 leonardolimafarias