waha icon indicating copy to clipboard operation
waha copied to clipboard

[WEBJS] - Cannot read properties of undefined (reading 'markedUnread') when calling api/sendText

Open vicentemarciot27 opened this issue 10 months ago • 43 comments

Describe the bug

Calling POST /api/sendText fails with a 500 Internal Server Error when trying to send a message.

The error is a TypeError:

Cannot read properties of undefined (reading 'markedUnread')

The stack trace shows it happens inside window.WWebJS.sendSeen when Client.sendMessage is called by WAHA:

TypeError: Cannot read properties of undefined (reading 'markedUnread')
    at window.WWebJS.sendSeen (evaluate at WPage.evaluate (...), <anonymous>:13:40)
    at #evaluate (.../ExecutionContext.js:391:56)
    at async ExecutionContext.evaluate (.../ExecutionContext.js:277:16)
    at async IsolatedWorld.evaluate (.../IsolatedWorld.js:100:16)
    at async CdpFrame.evaluate (.../Frame.js:362:20)
    at async CdpPage.evaluate (.../Page.js:818:20)
    at async WPage.evaluate (.../WPage.js:13:20)
    at async WebjsClientCore.sendMessage (.../whatsapp-web.js/src/Client.js:1100:25)
    at async descriptor.value (.../core/abc/activity.js:9:20)
    ...

So it looks like the code tries to access a markedUnread property on an undefined message/chat object while sending or marking the chat as seen.


Version

Result of GET /api/version (from the error payload):

{
  "version": "2026.1.2",
  "engine": "WEBJS",
  "tier": "CORE",
  "browser": "/usr/bin/chromium",
  "platform": "linux/x64"
}

Steps

To Reproduce

  1. Start WAHA with engine WEBJS and a running default session.
  2. Send a POST request to POST /api/sendText with a valid chatId and text.
  3. The server responds with HTTP 500.
  4. Docker logs show the TypeError: Cannot read properties of undefined (reading 'markedUnread') originating from window.WWebJS.sendSeen inside whatsapp-web.js Client.sendMessage.

Expected behavior

The text message should be sent successfully to the specified chatId, and the endpoint should return a success response (e.g. 200 OK with message info) without throwing any internal error related to markedUnread or sendSeen.


Requests - Responses

Request

POST /api/sendText
Content-Type: application/json

Body (personal data redacted):

{
  "chatId": "[email protected]",
  "text": "Hi there!",
  "session": "default"
}

Error Response (500)

{
  "statusCode": 500,
  "timestamp": "2026-01-14T14:11:21.980Z",
  "exception": {
    "message": "Cannot read properties of undefined (reading 'markedUnread')\nI (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1540:4171)\nObject.<anonymous> (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1540:1751)",
    "name": "TypeError",
    "stack": "TypeError: Cannot read properties of undefined (reading 'markedUnread')\nI (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1540:4171)\nObject.<anonymous> (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1540:1751)\n    at window.WWebJS.sendSeen (evaluate at WPage.evaluate (/app/dist/core/engines/webjs/WPage.js:13:36), <anonymous>:13:40)\n    at #evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:391:56)\n    at async ExecutionContext.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:277:16)\n    at async IsolatedWorld.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:100:16)\n    at async CdpFrame.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:362:20)\n    at async CdpPage.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:818:20)\n    at async WPage.evaluate (/app/dist/core/engines/webjs/WPage.js:13:20)\n    at async WebjsClientCore.sendMessage (/app/node_modules/whatsapp-web.js/src/Client.js:1100:25)\n    at async descriptor.value (/app/dist/core/abc/activity.js:9:20)\n    ..."
  },
  "request": {
    "path": "/api/sendText",
    "method": "POST",
    "body": {
      "chatId": "[email protected]",
      "text": "Hi there!",
      "session": "default"
    },
    "query": {}
  },
  "version": {
    "version": "2026.1.2",
    "engine": "WEBJS",
    "tier": "CORE",
    "browser": "/usr/bin/chromium",
    "platform": "linux/x64"
  }
}

Docker Logs


waha-1  | [14:11:21.981] INFO (47): request errored {"reqId":138,"req":{"id":138,"method":"POST","url":"/api/sendText","query":{},"params":{"path":["api","sendText"]}},"res":{"statusCode":500},"responseTime":46}
waha-1  |     err: {
waha-1  |       "type": "Error",
waha-1  |       "message": "Cannot read properties of undefined (reading 'markedUnread')\nI (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1540:4171)\nObject.<anonymous> (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1540:1751)",
waha-1  |       "stack":
waha-1  |           TypeError: Cannot read properties of undefined (reading 'markedUnread')
waha-1  |           I (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1540:4171)
waha-1  |           Object.<anonymous> (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1540:1751)
waha-1  |               at window.WWebJS.sendSeen (evaluate at WPage.evaluate (/app/dist/core/engines/webjs/WPage.js:13:36), <anonymous>:13:40)
waha-1  |               at #evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:391:56)
waha-1  |               at async ExecutionContext.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:277:16)
waha-1  |               at async IsolatedWorld.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:100:16)
waha-1  |               at async CdpFrame.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:362:20)
waha-1  |               at async CdpPage.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:818:20)
waha-1  |               at async WPage.evaluate (/app/dist/core/engines/webjs/WPage.js:13:20)
waha-1  |               at async WebjsClientCore.sendMessage (/app/node_modules/whatsapp-web.js/src/Client.js:1100:25)
waha-1  |               at async descriptor.value (/app/dist/core/abc/activity.js:9:20)
waha-1  |               at v (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1539:1311)
waha-1  |               at <anonymous> (https://static.whatsapp.net/rsrc.php/v4/yv/r/0p5QPbRp7Rp.js:106:276)
waha-1  |               at <anonymous> (https://static.whatsapp.net/rsrc.php/v4/yv/r/0p5QPbRp7Rp.js:106:407)
waha-1  |               at i (https://static.whatsapp.net/rsrc.php/v4/yv/r/0p5QPbRp7Rp.js:106:348)
waha-1  |               at l (https://static.whatsapp.net/rsrc.php/v4/yv/r/0p5QPbRp7Rp.js:106:124)
waha-1  |               at <anonymous> (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1539:1750)
waha-1  |               at I (https://static.whatsapp.net/rsrc.php/v4iiPd4/ya/l/en_US-j/JAfHf_4WnGs.js:1539:4170)
waha-1  |       "name": "TypeError"
waha-1  |     }

Additional context

  • Engine: WEBJS
  • Tier: CORE
  • Running on Linux (linux/x64) with Chromium binary at /usr/bin/chromium.
  • It looks like whatsapp-web.js (or the WAHA wrapper around it) is trying to call sendSeen on a chat/message that is not fully initialized or is undefined.
  • The bug might be related to chats that are archived/unavailable, or a recent change in WhatsApp Web where markedUnread no longer exists / is not present on some chat objects.

vicentemarciot27 avatar Jan 14 '26 14:01 vicentemarciot27

same error +1

tmzm avatar Jan 14 '26 14:01 tmzm

same error +1

vmotso avatar Jan 14 '26 14:01 vmotso

mismo error +1

Ciro-prog avatar Jan 14 '26 15:01 Ciro-prog

English


same error +1

github-actions[bot] avatar Jan 14 '26 15:01 github-actions[bot]

same error +1

sergiozaninotti avatar Jan 14 '26 15:01 sergiozaninotti

same error +1

CassioGirard avatar Jan 14 '26 15:01 CassioGirard

same error +1

claudiocnc avatar Jan 14 '26 16:01 claudiocnc

same error +1

akbarharyadi avatar Jan 14 '26 16:01 akbarharyadi

Possible solution go to NOWEB. Sending message working

Ciro-prog avatar Jan 14 '26 16:01 Ciro-prog

same error +1

edgaru avatar Jan 14 '26 16:01 edgaru

same error +1 only happens in WEBJS version, in GOWS works fine.

yanmcs avatar Jan 14 '26 16:01 yanmcs

same error +1

jhoabran avatar Jan 14 '26 16:01 jhoabran

same error +1 only happens in WEBJS version, in GOWS works fine.

How do you use GOWS?

jhoabran avatar Jan 14 '26 17:01 jhoabran

+1 Same issue. Switching to NOWEB also did not fix it.

Anirudh12345678 avatar Jan 14 '26 17:01 Anirudh12345678

Same here .. Since some time. But strangely my other 2 sessions are not impacted.

normalscene avatar Jan 14 '26 17:01 normalscene

Same error in WEBJS

patron:PRO

alvaromoura-nibo avatar Jan 14 '26 18:01 alvaromoura-nibo

Fixed for me after using the GOWS engine.

To run using GOWS: https://waha.devlike.pro/docs/engines/gows/

You wont have a Web Dashboard but you can use the Postman Plugin for WAHA, to configure sessions and get going

Anirudh12345678 avatar Jan 14 '26 18:01 Anirudh12345678

same here, service broken... any workarround or must downgrade ?

nmarquev avatar Jan 14 '26 18:01 nmarquev

same here!

sidroniolima avatar Jan 14 '26 18:01 sidroniolima

Another one, to keep service going i am receiving with waha and sending with z-api....but no long term solution

raulmonge05 avatar Jan 14 '26 19:01 raulmonge05