From 8f1370a18c9389fae46caf2587a3b8ae94bcab9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20dos=20Santos=20Junior?= <8673366+MarToxAk@users.noreply.github.com> Date: Sat, 7 Nov 2026 09:53:17 -0300 Subject: [PATCH] fix(baileys): ack top-level stanzas WhatsApp is rolling out delivery of contacts' statuses as a top-level stanza instead of . Baileys 7.0.0-rc13 has no handler for it, so it is never acked: the server ends the stream ~50 min later (stream:error ack class="status", code 500) and holds back new inbound messages for that session, which then stays "open" but receives nothing. Backport WhiskeySockets/Baileys#2883 via patch-package until it ships in a Baileys release. Fixes #2778 Co-Authored-By: Claude Opus 5.5 --- patches/baileys+7.0.0-rc13.patch | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 patches/baileys+7.0.0-rc13.patch diff --git a/patches/baileys+7.0.0-rc13.patch b/patches/baileys+7.0.0-rc13.patch new file mode 100644 index 0000000000..079b12e448 --- /dev/null +++ b/patches/baileys+7.0.0-rc13.patch @@ -0,0 +1,42 @@ +diff --git a/node_modules/baileys/lib/Socket/messages-recv.js b/node_modules/baileys/lib/Socket/messages-recv.js +index f2003ac..f6ef9e0 100644 +--- a/node_modules/baileys/lib/Socket/messages-recv.js ++++ b/node_modules/baileys/lib/Socket/messages-recv.js +@@ -1576,11 +1576,25 @@ export const makeMessagesRecvSocket = (config) => { + return exec(node, false).catch(err => onUnexpectedError(err, identifier)); + } + }; ++ // Some accounts now get contacts' statuses as a top-level stanza ++ // instead of . It isn't decoded here, but it ++ // must be acked: otherwise the server ends the stream ~50 minutes later with ++ // and holds back new messages. ++ // Backport of WhiskeySockets/Baileys#2883. ++ const handleStatus = async (node) => { ++ try { ++ await sendMessageAck(node); ++ } ++ catch (error) { ++ onUnexpectedError(error, 'acking status stanza'); ++ } ++ }; + const offlineNodeProcessor = makeOfflineNodeProcessor(new Map([ + ['message', handleMessage], + ['call', handleCall], + ['receipt', handleReceipt], +- ['notification', handleNotification] ++ ['notification', handleNotification], ++ ['status', handleStatus] + ]), { + isWsOpen: () => ws.isOpen, + onUnexpectedError, +@@ -1621,6 +1635,10 @@ export const makeMessagesRecvSocket = (config) => { + ws.on('CB:notification', async (node) => { + await processNode('notification', node, 'handling notification', handleNotification); + }); ++ ws.on('CB:status', async (node) => { ++ // processNode acks ignored JIDs itself, outside handleStatus' try/catch ++ await processNode('status', node, 'acking status stanza', handleStatus).catch(error => onUnexpectedError(error, 'acking status stanza')); ++ }); + ws.on('CB:ack,class:message', (node) => { + handleBadAck(node).catch(error => onUnexpectedError(error, 'handling bad ack')); + });