Skip to content

[BUG] messages.upsert not triggerd #1936

Description

@duola8789

Describe the bug

When using baileys version 6.7.20, the messages.upsert event is not triggered when sending messages to certain numbers if both the sender and receiver's official WhatsApp applications (Web or App) are offline. Through debugging, it was observed that the corresponding

ws.on('CB:receipt', node => {
    processNode('receipt', node, 'handling receipt', handleReceipt);
});

event does not receive any callbacks.

To Reproduce

  1. Create a WhatsApp connection using baileys 6.7.20
  2. Ensure both sender and receiver's official WhatsApp applications are offline
  3. Send a message to a target number through baileys
  4. Listen for the messages.upsert event
  5. Observe that the event is not triggered

Not all number can reproduce, but mine number and some user's can

Expected behavior
The messages.upsert event should be triggered

Environment (please complete the following information):

  • Is this on a server?
    Yes

  • What do your connectOptions look like?

   const socket = BaileysService.makeWASocket({
     // printQRInTerminal: true,
     browser: BaileysService.Browsers.macOS('Chrome'),
     msgRetryCounterCache,
     generateHighQualityLinkPreview: true,
     mobile: false,
     auth: {
       creds: state.creds,
       keys: BaileysService.makeCacheableSignalKeyStore(
         state.keys,
         pinLogger as unknown as any,
       ),
     },
     version,
     logger: pinLogger,
     syncFullHistory: true,
     cachedGroupMetadata: async (id) => await this.getGroups(id),
     shouldIgnoreJid: (jid) => BaileysService.isJidBroadcast(jid),
     getMessage: async (key) => {
       const data = await prisma.message.findUnique({
         where: {
           sessionId_remoteJid_id: {
             sessionId: this.id,
             remoteJid: BaileysService.jidNormalizedUser(key.remoteJid!),
             id: key.id!,
           },
         },
       });
       // console.log('socket-getMessage', key, data);
       return (data?.message || undefined) as proto.IMessage | undefined;
     },
     ...this.config,
   } as unknown as UserFacingSocketConfig);
  • Do you have multiple clients on the same IP?
    No
  • Are you using a proxy?\
  • Yes

Additional context

  • This may be related to WhatsApp's message delivery mechanism behavior when users are offline
  • Suggest investigating whether additional event listeners or configurations are needed to handle message receipts in offline scenarios

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