Skip to content

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

@freelabpop

Description

@freelabpop

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/1234567890@c.us/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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions