WhiskeySockets / Baileys

Lightweight full-featured typescript/javascript WhatsApp Web API
https://baileys.whiskeysockets.io/
MIT License
3.96k stars 1.34k forks source link

[BUG] Losing some Messages in Baileys WhatsApp API #668

Closed lucasdoctype closed 7 months ago

lucasdoctype commented 8 months ago

Hello,

I am currently developing a WhatsApp application using the Baileys WhatsApp API, and I've encountered an issue where some messages are getting lost or not being captured by my event listeners. I have set up listeners for "messages.upsert" and "messages.update" events to handle incoming and updated messages respectively. Here is a simplified version of my setup:

wsocket = makeWASocket({ logger: loggerBaileys, printQRInTerminal: false, auth: state as AuthenticationState, version, msgRetryCounterCache, getMessage: async key => { if (store) { const msg = await store.loadMessage(key.remoteJid!, key.id!); return msg?.message || undefined; } } });

Handling messages.upsert Event:

wbot.ev.on("messages.upsert", async (messageUpsert) => { logger.info(RECEIVED FROM BAILEYS -> ${JSON.stringify(messageUpsert?.messages[0])}); const messages = messageUpsert.messages.filter(filterMessages).map(msg => msg); if (messages == null || messages.length === 0 || messages === undefined ) return; messagesArray.push({msg: messages[0], wbot}); });

wbot.ev.on("messages.update", (messageUpdate) => { logger.info(RECEIVED FROM BAILEYS MESSAGES_UPDATE -> ${JSON.stringify(messageUpdate)}); if (messageUpdate.length === 0) return; messageUpdate.forEach(async (message) => { handleMsgAck(message, message.update.status); }); });

Despite this setup, I'm noticing that some messages are either not being captured by the event listeners or are being lost before they can be handled. This issue is causing significant gaps in the message flow, and I'm concerned about the reliability of message capture for my application's functionality.

Could you provide any insights or recommendations on how to ensure that all messages are reliably captured and no messages are lost? Are there any additional events or error handling mechanisms that I should implement to address this issue?

Thank you for your assistance.

jefaokpta commented 8 months ago

Seems like my issue https://github.com/WhiskeySockets/Baileys/issues/670

lucasdoctype commented 8 months ago

unfortunately :(

Riders004 commented 8 months ago

Waiting for message issue ?