fix(baileys): stop resending stale messages on retry receipts - #2707
Closed
maximbaran wants to merge 0 commit into
Closed
fix(baileys): stop resending stale messages on retry receipts#2707maximbaran wants to merge 0 commit into
maximbaran wants to merge 0 commit into
Conversation
Contributor
Reviewer's GuidePrevents Baileys retry receipts from rebroadcasting stale WhatsApp messages by restricting socket lookups to the last 15 minutes, while preserving poll-related lookups and skipping retries when message content is unavailable. Sequence diagram for age-limited WhatsApp retry resendsequenceDiagram
participant Peer
participant Baileys
participant SocketGetMessage
participant Database
Peer->>Baileys: retry receipt
Baileys->>SocketGetMessage: getMessage(key, false, true)
SocketGetMessage->>Database: query message by key
alt message missing
Database-->>SocketGetMessage: no result
SocketGetMessage-->>Baileys: undefined
Baileys-->>Peer: skip resend
else message older than 15 minutes
Database-->>SocketGetMessage: messageTimestamp
SocketGetMessage-->>Baileys: undefined
Baileys-->>Peer: skip resend
else recent message
Database-->>SocketGetMessage: message and timestamp
SocketGetMessage-->>Baileys: message content
Baileys-->>Peer: resend message
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the age check is wrong or Baileys timestamps are missing or inconsistent, valid retry requests for messages older than 15 minutes will return no content and some recipients may never receive those messages. Reverting restores the old callback behavior, but deliveries already missed may require a retry or other bounded repair.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a peer fails to decrypt a message it sends a retry receipt, and Baileys replays whatever the socket getMessage callback returns. Since the callback served any message ever stored, a reconnect that flushed a backlog of queued retry receipts could rebroadcast days-old messages, which reappeared in groups as brand-new ones.
The socket callback now only serves messages younger than 15 minutes (poll creation messages stay exempt so vote decryption keeps working), and getMessage returns undefined instead of an empty conversation when the message is missing, so Baileys skips the resend instead of sending a blank bubble.
📋 Description
🔗 Related Issue
Closes #(issue_number)
🧪 Type of Change
🧪 Testing
📸 Screenshots (if applicable)
✅ Checklist
📝 Additional Notes
Summary by Sourcery
Prevent stale or empty messages from being rebroadcast during Baileys retry handling.
Bug Fixes:
Chores: