Skip to content

🐞 [BUG] messages.upsert event not triggered under high message load #1879

Description

@ecatugy

🐞 [BUG] messages.upsert event not triggered under high message load

Describe the bug
When the instance receives a high volume of incoming messages, the messages.upsert event occasionally stops being triggered for some clients. As a result, certain user flows cannot respond to those messages because the event is never fired. This happens sporadically across a few instances and seems correlated with high incoming message volume.
It’s not a hardware limitation the server has significantly more resources than required for normal operation.

To Reproduce

  1. Create a new Baileys connection.
  2. Start receiving a large number of incoming messages in a short period.
  3. Observe that at some point, messages.upsert stops being emitted for certain messages.

Expected behavior
The messages.upsert event should always be triggered for every incoming message, regardless of message volume or load.

Environment (please complete the following information):

  • Baileys version: 7.0.0-rc.5
  • Server environment: Yes
  • Multiple clients on the same IP: Sometimes
  • Using proxy: No
  • connectOptions:
    {
    markOnlineOnConnect: false,
    syncFullHistory: false,
    generateHighQualityLinkPreview: false,
    connectTimeoutMs: 5 * 60 * 1000,
    defaultQueryTimeoutMs: 5 * 60 * 1000
    }

Additional context
I skip specific message types in my message handler, as shown below:

// Skip processing group messages
if (
  m?.key?.remoteJid?.endsWith('@g.us') ||
  m?.key?.remoteJid?.endsWith('@broadcast') ||
  m?.key?.remoteJid?.endsWith('@newsletter') ||
  m?.key?.remoteJid === 'status@broadcast'
) {
  continue;
}

The skipped messages include:

  • Group chat messages (@g.us)
  • Broadcast messages (@broadcast)
  • Newsletter messages (@newsletter)
  • Status updates (status@broadcast)

Even with these filters, the issue still occurs occasionally when message throughput is high.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions