Skip to content

fix(baileys): ack top-level <status> stanzas (fixes #2778) - #2785

Open
MarToxAk wants to merge 1 commit into
evolution-foundation:developfrom
MarToxAk:fix/baileys-ack-status-stanza
Open

MarToxAk wants to merge 1 commit into
evolution-foundation:developfrom
MarToxAk:fix/baileys-ack-status-stanza

Conversation

@MarToxAk

@MarToxAk MarToxAk commented Nov 7, 2026 •

Copy link
Copy Markdown

Summary

Fixes #2778.

WhatsApp is gradually rolling out a change that delivers contacts' statuses as a top-level <status> stanza instead of <message from="status@broadcast">. Baileys 7.0.0-rc13 (and rc.9, used by 2.3.7 / 2.4.0-rc2) only registers handlers for message, call, receipt and notification, so a <status> is never acked.

Effects seen in production:

  • ~50 minutes after connecting, the server ends the stream with {"tag":"stream:error","content":[{"tag":"ack","attrs":{"class":"status","type":"media",...}}]} (Stream Errored (ack), statusCode 500). Every instance reconnects every ~50 min.
  • More importantly, while the <status> waits for its ack, the server holds back new inbound messages for that session. The instance stays open, sending works, but nothing is received — no Message row, no messages.upsert webhook. Instance restart and container restart do not fix it; a new QR only helps for a few hours.
  • Instances whose contacts post many statuses (business numbers with large contact lists) are hit first.

Fix

Backport of the upstream fix WhiskeySockets/Baileys#2883 through patch-package (the patches/ directory and postinstall hook already exist for this):

  • add handleStatus, which acks the node via the existing sendMessageAck (the stanza is not decoded);
  • route CB:status through processNode, and register ['status', handleStatus] in the offline node processor so offline <status> nodes are acked in order;
  • failures are reported through onUnexpectedError instead of breaking the offline queue.

The patch can be dropped once a Baileys release includes #2883.

Testing

  • patch-package applies cleanly on a fresh install of [email protected]; the module imports fine.
  • The same change (on the compiled rc.9 shipped in evoapicloud/evolution-api:2.4.0-rc2) has been running in production on a server with 6 QR instances + Chatwoot:
    • before: one instance stopped receiving entirely for ~13 h; debug logs showed 229 <status> frames logged as unhandled in 5 minutes and no ack;
    • after: 951 <status> stanzas acked in the first 3 minutes, 0 unhandled, 0 errors; the server released the held-back inbound messages within ~1 minute and the instance kept receiving — no QR re-scan needed.

🤖 Generated with Claude Code

Summary by Sourcery

Restore reliable Baileys message reception by acknowledging top-level status stanzas.

Bug Fixes:

  • Ensure top-level WhatsApp stanzas are acknowledged so inbound message delivery does not stall and recurring stream errors are avoided.

Build:

  • Add a patch-package patch for Baileys 7.0.0-rc13 to apply the status-stanza acknowledgement fix.

WhatsApp is rolling out delivery of contacts' statuses as a top-level
<status> stanza instead of <message from="status@broadcast">. 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 evolution-foundation#2778

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Configuration

Add a patch-package patch to Baileys that acknowledges top-level status stanzas, including those processed offline.

  • patches/baileys+7.0.0-rc13.patch L1-42

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant