evolution-api icon indicating copy to clipboard operation
evolution-api copied to clipboard

Private messages remain PENDING while group messages work (v2.3.7)

Open gustavogabrielpereirarech1-coder opened this issue 4 months ago • 20 comments

Welcome!

  • [x] Yes, I have searched for similar issues on GitHub and found none.

What did you do?

Describe the bug

Private messages are never delivered.

The API returns 201 Created, but every private message remains permanently PENDING.

Group messages are delivered normally.

Environment

  • Evolution API: v2.3.7
  • Railway
  • PostgreSQL
  • Redis
  • WhatsApp Multi Device

Steps to reproduce

  1. Create a new instance.
  2. Scan a new QR Code.
  3. Wait until the instance is connected.
  4. Send a message to a private contact.
  5. The API returns 201 but the message stays PENDING forever.

Expected behavior

The private message should be delivered.

Actual behavior

  • Private chats: ❌ Always PENDING
  • Group chats: ✅ Working normally
  • Receiving messages: ✅ Working normally

Logs

Sending message to [email protected]

status: 1

Update messages
status: 0
messageStubParameters: ["463"]

stream errored out

Additional information

Already tested:

  • New instance
  • New QR Code
  • Different private contacts
  • Sending from Evolution UI
  • Sending through /message/sendText
  • n8n removed from the test
  • Typebot removed from the test

The problem remains the same.

What did you expect?

The issue only affects private chats.

What has already been verified:

  • Fresh instance created from scratch.
  • New QR Code scanned.
  • WhatsApp connection established successfully.
  • Receiving messages works correctly.
  • Sending messages to groups works correctly.
  • Sending messages to private contacts always remains in PENDING.
  • The API returns HTTP 201 Created.
  • The logs show Sending message..., followed by status: 0, messageStubParameters: ["463"], and sometimes stream errored out.
  • The same behavior occurs when sending from the Evolution UI and through the /message/sendText endpoint.
  • n8n and Typebot were removed from the tests, so they are not involved in the issue.

If any additional logs or debug information are required, I can provide them.

What did you observe instead of what you expected?

When sending a message to any private WhatsApp contact, the Evolution API returns HTTP 201 Created, but the message remains permanently in the PENDING state and is never delivered.

The logs show that Baileys attempts to send the message (Sending message to...), but the status changes to 0 and never progresses to a delivered state. In some cases, stream errored out also appears in the logs.

The same behavior occurs when sending from the Evolution UI and through the /message/sendText endpoint.

Receiving messages works correctly, and sending messages to WhatsApp groups also works correctly. The problem only affects private chats.

Screenshots/Videos

No response

Which version of the API are you using?

Evolution API: v2.3.7 Baileys: 2.3000.1042581539

What is your environment?

Docker

Other environment specifications

No response

If applicable, paste the log output

No response

Additional Notes

No response

estou com o mesmo problema.

joesantos1 avatar Jul 03 '26 01:07 joesantos1

Amigo, estou investigando o mesmo cenário aqui no laboratório. Para nos ajudar a isolar o problema e passar o relatório limpo para os desenvolvedores, você poderia confirmar:Qual é a versão exata da Evolution API que você está rodando?Você está usando Baileys?No seu caso, o envio para grupos também funciona normal e apenas o chat privado fica travado em PENDING?Seus logs mostram o parâmetro 463 ou stream errored out?

Amigo, estou investigando o mesmo cenário aqui no laboratório. Para nos ajudar a isolar o problema e passar o relatório limpo para os desenvolvedores, você poderia confirmar:Qual é a versão exata da Evolution API que você está rodando?Você está usando Baileys?No seu caso, o envio para grupos também funciona normal e apenas o chat privado fica travado em PENDING?Seus logs mostram o parâmetro 463 ou stream errored out?

usando a versao 2.3.7 - usando baileys - apenas envio em chat privado fica pending ...

joesantos1 avatar Jul 03 '26 11:07 joesantos1

Perfeito! Seu relato confirma exatamente o que isolei aqui no meu laboratório de testes. Rodando a v2.3.7 com Baileys em um container totalmente limpo e com outro chip, o comportamento é idêntico: Grupos funcionam 100%, mas chats privados travam em PENDING eterno e geram erro de protocolo visual (Unknown message type: protocolMessage).Isso mata a hipótese de ser erro de infraestrutura individual (banco, n8n ou Railway) e aponta para uma falha global no processamento do evento de retorno (ACK/messages.update) em chats 1:1 nessa versão.Já estamos auditando o código-fonte do fluxo de eventos para achar a linha exata do bug. Se você descobrir alguma branch de correção ou se o seu log mostrar alguma exceção específica no listener de mensagens privadas, joga aqui para cruzarmos os dados!

Bug Analysis & Technical Context

We have isolated the technical context behind the perpetual PENDING status issue in private chats after running controlled tests on sandbox environments (reproduced across versions v2.3.6, v2.3.7, and v2.4.0-rc2).

Symptoms

While group messages (@g.us) flow and update perfectly, individual messages (1:1) get stuck in a perpetual PENDING state and trigger a visual protocol error interface-side (Unknown message type: protocolMessage).

Observed Behavior & Identity Mismatch

  1. Jid Variance: The message is originally sent using the standard phone number JID (@s.whatsapp.net). However, the incoming ACK payload contains a different remoteJid representation (@lid) than the original outgoing message JID, causing an identity mismatch during message reconciliation.
  2. Lookup & Persistence Failure: During the execution of connectionUpdate() or the message listener handler, the application attempts to correlate the incoming status change. The message store lookup fails to match the incoming @lid payload against the stored @s.whatsapp.net record, leading to an update failure or silent drop in the database/cache layer.

Recommendation / Fix Direction

Message reconciliation should be strictly based on messageKey.id as the immutable identifier. remoteJid should not be used as a primary correlation key due to observed protocol-level variance in private chat ACK payloads.

As a quick workaround at the event adapter layer, a JID normalizer can be enforced to clean incoming namespaces before database persistence:

export function normalizeJid(jid?: string) {
  if (!jid) return jid;
  return jid.replace(/@lid/g, '@s.whatsapp.net');
}

will this be update ?

t1t0l avatar Jul 03 '26 17:07 t1t0l

Did anyone manage to solve it?

saullof avatar Jul 05 '26 17:07 saullof

Not yet

Any news about this bug? still cant manage to work around it...

hfogli avatar Jul 06 '26 15:07 hfogli

How do I solve this? I'm having the same problem

Dbszin avatar Jul 06 '26 19:07 Dbszin

estou utilizando a infra da propria whatsevolution, sem previsão para solução por la ?

hashdefault avatar Jul 06 '26 22:07 hashdefault

I'm having the same problem. This workaround did NOT fix the issue on my end, but may be worth trying https://github.com/evolution-foundation/evolution-api/issues/2597#issuecomment-4928074148

dangarciahe avatar Jul 10 '26 00:07 dangarciahe

Same here, any update?

crosspopz avatar Jul 21 '26 18:07 crosspopz

After a few days, you may notice that there has been a temporary block on your WhatsApp if the number has been listed for a long time or is not "followed"

Dbszin avatar Jul 21 '26 18:07 Dbszin

463 en envíos 1:1 + bug en OnWhatsappCache + workaround con LID

Repro en v2.3.7 (también v2.3.6 y v2.4.0-rc2): mensaje privado a un contacto conocido usando el JID de teléfono se queda pegado — status: 1 → status: 0, messageStubParameters: ["463"]. Nunca se entrega.

Los mensajes entrantes del mismo contacto sí resuelven el LID correctamente vía remoteJidAlt:

JS key: { remoteJid: '14156280996xxxx@lid', remoteJidAlt: '[email protected]', addressingMode: 'lid' } Justo después, los logs muestran una clave de caché malformada:

LOG [saveOnWhatsappCache] [email protected]@s.whatsapp.net Sufijo duplicado (@[email protected]). Podría ser la causa de que fallen los lookups en el flujo de envío.

Workaround (empírico): enviando directo al LID en vez del JID de teléfono, el mensaje sí llegó:

JSON { "number": "14156280996xxxx@lid", "text": "..." } JID de teléfono → 463. LID → entregado. Mismo contacto, misma instancia. No es un fix real, pero puede ayudar a ubicar dónde se rompe el flujo de envío.

Andres-Cuellar avatar Jul 23 '26 16:07 Andres-Cuellar

Additional report: same symptom, reproduced and partially isolated

I'm hitting the exact same behavior described in this issue and I wanted to add my findings, since I was able to isolate part of the root cause and found a partial workaround that might help narrow down the fix.

Environment

  • Evolution API: 2.3.7
  • Baileys (pinned dependency): 7.0.0-rc.9 (originally)
  • Integration: WHATSAPP-BAILEYS
  • Database: PostgreSQL (Prisma)
  • Cache: Redis (CACHE_REDIS_ENABLED=true)
  • Chatwoot integration: enabled (CHATWOOT_ENABLED=true)
  • Deployment: Docker (Easypanel)

Symptom

Outgoing messages to a specific contact are accepted by the API (201 Created / PENDING), but never get past a single check mark. The message update event shows:

{
  "key": {
    "remoteJid": "[email protected]",
    "fromMe": true,
    "id": "..."
  },
  "update": {
    "status": 0,
    "messageStubParameters": ["463"]
  }
}

Right before this, the logs show Baileys closing and re-negotiating the Signal session on every single send, for the same contact:

Closing session: SessionEntry {
  registrationId: XXXXXXXXX,
  indexInfo: { baseKeyType: 1, closed: -1, used: ..., created: ... },
  ...
}

In a healthy session this should only happen once, not on every outgoing message.

What I ruled out

  • Not a Chatwoot/webhook config issue (verified webhook/find and chatwoot/find, both correctly pointed).
  • Not Postgres/Redis corruption — fully deleted the instance (/instance/delete), recreated it from scratch with a brand new instanceId, re-scanned the QR. Same registrationIds (i.e. same receiving-side devices) failed identically with a totally fresh session on my side.
  • Not a replica/duplicate-process issue — confirmed single replica, single container.
  • Not specific to one contact — reproduced with two different, unrelated phone numbers.
  • The same WhatsApp account sends successfully via the official WhatsApp Web client, but fails consistently via Baileys/Evolution — matching what's described in #2633.

Correlation with WhatsApp LID migration

Looking closer at the logs, the affected contacts are ones that have migrated to WhatsApp's new LID identity system. Example from the Chatwoot handler:

[OnWhatsappCache] [saveOnWhatsappCache] Register exists, updating: [email protected], [email protected]@s.whatsapp.net, lid=null
...(next message, same contact, seconds later)...
[OnWhatsappCache] [saveOnWhatsappCache] Register exists, updating: [email protected], [email protected]@s.whatsapp.net, lid=lid

The internal OnWhatsappCache flips between lid=null and lid=lid for the same contact between consecutive sends. My hypothesis is that this inconsistency in how the addressing mode is resolved is what forces Baileys to keep tearing down and rebuilding the Signal session, which eventually produces a ciphertext the receiving device can't decrypt (stub 463).

What I tried

  1. Bumped baileys from 7.0.0-rc.9 → 7.0.0-rc13 in a fork. No breaking changes to Evolution's usage (all imported functions/types still present). This alone did not fix the delivery issue — same status: 0 / stub 463 behavior persisted after the bump, with a completely fresh instance.
  2. As a stopgap, I patched ChatwootService's message handler to force remoteJidAlt (the real phone number) over remoteJid whenever the latter is a @lid identifier, right at the entry point of the messages.upsert / send.message handler:
if (event === 'messages.upsert' || event === 'send.message') {
  // Stopgap: WhatsApp LID migration workaround
  if (body?.key?.remoteJid?.includes('@lid') && body?.key?.remoteJidAlt) {
    body.key.remoteJid = body.key.remoteJidAlt;
  }
  ...

This fixes Chatwoot contact/conversation creation (no longer keyed by the long LID number), but doesn't by itself resolve the underlying send failure — that part still seems to live inside Baileys' session handling for LID-migrated contacts specifically.

Question for maintainers

Is the root cause understood to be inside Baileys' Signal session management for @lid-addressed contacts, or is there additional normalization Evolution is expected to do before calling sock.sendMessage() (e.g. resolving to the phone-number JID consistently before every send, not just on receive)? Happy to share full verbose logs (redacted) or test a patch if it'd help narrow this down further.

hfebles avatar Jul 23 '26 20:07 hfebles

Por acá presentando exactamente el mismo problema, incluso con restricciones impuestas por META a algunas cuentas con falta de interacción bidireccional. Alguien pudo avanzar con la solución?

erikam-stack avatar Jul 27 '26 18:07 erikam-stack

Por acá presentando exactamente el mismo problema, incluso con restricciones impuestas por META a algunas cuentas con falta de interacción bidireccional. Alguien pudo avanzar con la solución?

Lo unico que pude hacer fue cambiar a waha, ya que ahora plus es gratis

Andres-Cuellar avatar Jul 27 '26 19:07 Andres-Cuellar

Hoy re-conecté nodos y "milagrosamente" toto está funcionando ok otra vez

erikam-stack avatar Jul 29 '26 20:07 erikam-stack

Same symptom here on v2.3.7. I think I've narrowed down the root cause — sharing the full evidence in case it helps.

Symptom

Outgoing text to private chats: the API returns success with a valid message id, status stays PENDING forever, and the message never arrives. Receiving works perfectly. Sending to the instance's own number (self-chat) does deliver.

Evidence this is not a WhatsApp-side ban or a companion-session restriction

  • Sending manually from the same phone to the same recipient: delivers.
  • WhatsApp Web, linked to the same account at the same time: delivers. WhatsApp Web is also a companion/linked device, so WhatsApp is clearly not restricting companion sessions on this account.
  • Fresh instance + fresh QR pairing with a clean DB (0 contacts / 0 chats): same behaviour.
  • Passing number as bare digits instead of the full @s.whatsapp.net JID: no change.

Likely root cause: Baileys 7.0.0-rc.9 LID send bug

The affected conversation is LID-addressed. Webhook payload of the incoming message:

"key": {
  "remoteJid": "<phone>@s.whatsapp.net",
  "remoteJidAlt": "<phone>@s.whatsapp.net",
  "fromMe": false,
  "addressingMode": "lid"
}

Server logs also reference the same contact internally as <id>@lid.

Per the CHANGELOG, v2.3.7 pins Baileys 7.0.0-rc.9. There is a documented Baileys bug in that era where sends to fully LID-migrated targets are silently dropped (repeated ack 479 for @lid device JIDs), fixed upstream in v7.0.0-rc13:

https://github.com/NousResearch/hermes-agent/issues/43830

That reporter confirmed the bump resolves delivery without re-pairing the session.

This would also explain why self-chat still works: it does not go through LID resolution.

Blocker: the homolog tag (2.4.0) does not boot

I tried the homolog image to test a newer Baileys. It crashes at startup during migrations:

> [email protected] db:deploy
Prisma schema loaded from prisma/postgresql-schema.prisma
Error: The datasource.url property is required in your Prisma config file when using prisma migrate deploy
Migration failed

This happens even though the log line immediately above prints a valid Database URL: postgresql://..., and it still happens with DATABASE_URL explicitly set alongside DATABASE_CONNECTION_URI. So there is currently no published image that lets us test the newer Baileys.

Request

Could Baileys be bumped to 7.0.0-rc13 (or newer) in a stable release? And could the 2.4.0 Prisma config issue be looked at, since it currently blocks testing the fix?


Environment: Evolution API v2.3.7 (Docker evoapicloud/evolution-api:latest), PostgreSQL + Redis, Baileys channel.

mohammad-sharif99 avatar Aug 10 '26 23:08 mohammad-sharif99