waha icon indicating copy to clipboard operation
waha copied to clipboard

[WEBJS] - GET /api/{session}/chats/{chatId}/messages returns 500 - Cannot read properties of undefined (reading 'waitForChatLoading')

Open freelabpop opened this issue 7 months ago • 5 comments

GET /api/{session}/chats/{chatId}/messages intermittently returns a 500 error with TypeError: Cannot read properties of undefined (reading 'waitForChatLoading'). The route works sometimes and fails other times for the same chatId. The error occurs regardless of the chatId format (@c.us or @lid).

Version

Get the WAHA version by calling GET /api/version

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

Steps

To Reproduce Steps to reproduce the behavior:

  1. Start a WAHA session with WEBJS engine
  2. Call GET /api/default/chats/[email protected]/messages?limit=10
  3. Sometimes returns messages correctly, sometimes returns 500

Expected behavior

Should consistently return the list of messages for the given chat.

Requests - Responses

Request:

GET /api/default/chats/1234567890%40c.us/messages?sortBy=timestamp&sortOrder=desc&downloadMedia=false&merge=true&limit=10

Response:

{
"statusCode": 500,
"timestamp": "2026-04-08T10:54:26.498Z",
"exception": {
"message": "Cannot read properties of undefined (reading 'waitForChatLoading')",
"name": "TypeError",
"stack": "TypeError: Cannot read properties of undefined (reading 'waitForChatLoading')\n    at evaluate (evaluate at WPage.evaluate (/app/dist/core/engines/webjs/WPage.js:13:36))\n    at async WebjsClientCore.getMessages (/app/dist/core/engines/webjs/WebjsClientCore.js:171:26)\n    at async WhatsappSessionWebJSCore.getChatMessages (/app/dist/core/engines/webjs/session.webjs.core.js:597:26)"
},
"request": {
"path": "/api/default/chats/1234567890%40c.us/messages",
"method": "GET",
"query": {
"sortBy": "timestamp",
"sortOrder": "desc",
"downloadMedia": "false",
"merge": "true",
"limit": "10"
}
},
"version": {
"version": "2026.3.4",
"engine": "WEBJS",
"tier": "CORE",
"browser": "/usr/bin/chromium",
"platform": "linux/x64"
}
}

Docker Logs

N/A

Screenshots

N/A

Additional context

  • The error is intermittent — same chatId works sometimes and fails other times
  • Occurs with both @c.us and @lid chatId formats
  • Tested on versions 2026.3.2 and 2026.3.4, same behavior
  • Docker Compose deployment on linux/x64
  • Suspected cause: WhatsApp Web internal JS update (r7KAd4T0ZuM.js) changed the internal API making waitForChatLoading intermittently undefined

freelabpop avatar Apr 08 '26 11:04 freelabpop

this pr was opened a while ago on WEBJS project with a possible fix https://github.com/wwebjs/whatsapp-web.js/issues/201706

claudiocnc avatar Apr 08 '26 12:04 claudiocnc

✅ Ready and available in dev images

Make sure to select the engine via the environment variable - WHATSAPP_DEFAULT_ENGINE=WEBJS:

  • devlikeapro/waha-plus:dev
  • devlikeapro/waha-plus:dev-chrome
  • devlikeapro/waha-plus:dev-arm

🕛 Note: Dev images are published nightly at 00:00 UTC, so new builds become available right after midnight UTC.

🚀 Will be included in the next release!

patron:PRO

devlikepro avatar Apr 13 '26 10:04 devlikepro

Same error using devlikeapro/waha-plus:dev-chrome

patron:PRO

alvaromoura-nibo avatar Apr 13 '26 16:04 alvaromoura-nibo

Apparently, this is a high impact error. Can you guys release a new version with the fix please?

patron:PRO

alvaromoura-nibo avatar Apr 14 '26 00:04 alvaromoura-nibo

2026.4.1 - WEBJS - fix loading messages - #2005, #2013

patron:PRO

devlikepro avatar Apr 15 '26 06:04 devlikepro