WhiskeySockets / Baileys

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

[BUG] Waiting Message on Groups with GetMessage and store already implemented #875

Open marcelotadeujr opened 3 months ago

marcelotadeujr commented 3 months ago

Describe the bug Hi, I have one server with around 20 "instances" connected and running very well on private messages, but i'm getting some "Waiting Message" when sending messages to Groups over Baileys API. I Already implemented the GetMessage function using the store pluget to socket ev. Can someone help me with this?

Thanks!

Proof: waiting

cloud

code

Environment (please complete the following information):

Additional context Messages are deliveried successfuly on private messages, this "waiting message" issue occours only on Groups.

thecharles commented 3 months ago

I am having the same problem.

clonazepanico commented 3 months ago

I'm having the same problem. It's even happening intermittently.

dephea commented 3 months ago

I also experience it in private chats

renatoiub commented 3 months ago

Try to do

getMessage: (key) => { return (store.loadMessage(key.remoteJid, key.id))?.message || undefined; }

IanosJunior commented 3 months ago

Me too. Only groups.

roysG commented 2 months ago

Same issue, some of the customers get this message

manojsitapara commented 2 months ago

same

bossdeep commented 1 month ago

same... any update on this? intermittent, but seems to be triggered by groups.

hacxk commented 1 month ago

Try this i am not sure but when i implement this i feel small fix try your self

  const sock = await makeWASocket({
            printQRInTerminal: true,
            mobile: false,
            keepAliveIntervalMs: 10000,
            downloadHistory: false,
            msgRetryCounterCache,
            syncFullHistory: true,
            shouldSyncHistoryMessage: msg => {
                console.log(chalk.cyanBright(`Syncing chats..[${msg.progress}%]`));
                return !!msg.syncType;
            },
            markOnlineOnConnect: true,
            defaultQueryTimeoutMs: undefined,
            logger,
            Browsers: ['BUDDY-MD', 'Chrome', '113.0.5672.126'],
            auth: {
                creds: state.creds,
                keys: makeCacheableSignalKeyStore(state.keys, logger),
            },
            linkPreviewImageThumbnailWidth: 1980,
            generateHighQualityLinkPreview: true,
            getMessage: async (key) => {
                if (store) {
                    const msg = await store.loadMessage(key.remoteJid, key.id)
                    return msg?.message || undefined
                }
                return {
                    conversation: ''
                }
            },
            patchMessageBeforeSending: async (msg, recipientJids) => {
                await sock.uploadPreKeysToServerIfRequired();
                return msg;
            }
        });

Always try to sync history messages it can fix a little also use await


sock.ev.on('messages.upsert', async ({ messages }) => {
            const m = messages[0];
            try {
                logger.debug(this.chalk.blue(`📩 Upserted message:`), m);
            } catch (error) {
                logger.error(this.chalk.red(`❌ Error handling messages.upsert event:`), error);
            }
        });