#1943·waha

[BUG][WEBJS] `TypeError: Cannot read properties of undefined (reading 'getContact'/'getChat')` on `/api/contacts` and `/api/sendText`

Author: jesaiasmaiaCreated Mar 4, 2026Updated Sep 16, 2026
Labelsbugengine:WEBJS

Describe the bug

On WAHA 2026.2.2 (WEBJS, PLUS), requests to GET /api/contacts and POST /api/sendText are intermittently failing with HTTP 500.

The internal stack trace points to whatsapp-web.js evaluate context:

  • WebjsClientPlus.getContactById -> reading 'getContact'
  • WebjsClientPlus.sendMessage -> reading 'getChat'

This happens even for simple text messages and valid @c.us numbers.

WAHA version

json
{
  "version": "2026.2.2",
  "engine": "WEBJS",
  "tier": "PLUS",
  "browser": "/usr/bin/chromium",
  "platform": "linux/x64"
}

Request samples
Failing contacts lookup
GET /api/contacts?contactId=5511999640873@c.us&session=<session_name>

Response:

{
  "statusCode": 500,
  "exception": {
    "message": "Cannot read properties of undefined (reading 'getContact')",
    "stack": "TypeError: Cannot read properties of undefined (reading 'getContact') ... at WebjsClientPlus.getContactById ..."
  }
}

Failing text send
POST /api/sendText

Response/log:

{
  "statusCode": 500,
  "err": {
    "message": "Cannot read properties of undefined (reading 'getChat')",
    "stack": "TypeError: Cannot read properties of undefined (reading 'getChat') ... at WebjsClientPlus.sendMessage ..."
  }
}

Steps to reproduce
Create/start a WEBJS session in WAHA PLUS.
Confirm session is WORKING.
Call:
GET /api/contacts?contactId=<phone>@c.us&session=<session>
Or call:
POST /api/sendText with valid session, chatId, and plain text.
Observe intermittent HTTP 500 with getContact or getChat undefined.
Expected behavior
/api/contacts should return contact data or a domain error (not runtime TypeError).
/api/sendText should send plain text successfully.
Actual behavior
Runtime TypeError inside WEBJS evaluate context (undefined.getContact / undefined.getChat), returning HTTP 500.
Additional context
Restart/logout of session may temporarily help, but issue can reappear.
Looks like internal WEBJS state/context inconsistency.