Re-request undecryptable messages from the phone instead of dropping them - #156
Open
6justgotme wants to merge 1 commit into
Open
Re-request undecryptable messages from the phone instead of dropping them#1566justgotme wants to merge 1 commit into
6justgotme wants to merge 1 commit into
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR enables automatic re-requesting of undecryptable messages from the primary phone so that previously dropped first-contact messages are recovered and delivered as normal events. Sequence diagram for automatic rerequest of undecryptable messagessequenceDiagram
actor Sender
participant WhatsAppServer
participant PrimaryPhone
participant LinkedDevice
participant WebhookEndpoint
Sender->>WhatsAppServer: send_message
WhatsAppServer->>PrimaryPhone: deliver_message
PrimaryPhone->>WhatsAppServer: sync_decrypted_message
WhatsAppServer->>LinkedDevice: deliver_message
LinkedDevice->>LinkedDevice: events.UndecryptableMessage
alt [AutomaticMessageRerequestFromPhone enabled]
LinkedDevice->>PrimaryPhone: AutomaticMessageRerequestFromPhone
PrimaryPhone->>WhatsAppServer: resend_message
WhatsAppServer->>LinkedDevice: events.Message
LinkedDevice->>WebhookEndpoint: webhook_POST
else [AutomaticMessageRerequestFromPhone disabled]
LinkedDevice->>LinkedDevice: log_and_drop_message
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider making
AutomaticMessageRerequestFromPhoneconfigurable viaClientDataor service options instead of hardcoding it to true, so operators can explicitly opt in or out of the rerequest behavior per deployment. - The new inline comment is in Portuguese; for consistency across the codebase, consider rewriting it in the predominant project language and briefly summarizing the behavior change rather than its full rationale.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider making `AutomaticMessageRerequestFromPhone` configurable via `ClientData` or service options instead of hardcoding it to true, so operators can explicitly opt in or out of the rerequest behavior per deployment.
- The new inline comment is in Portuguese; for consistency across the codebase, consider rewriting it in the predominant project language and briefly summarizing the behavior change rather than its full rationale.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…Phone Companion/multi-device deployments drop the first message from new contacts when it fails to decrypt: whatsmeow emits UndecryptableMessage and the event handler skips the webhook (only view_once / ID 66-67 are handled), with no retry, so the message is lost. Enable whatsmeow's AutomaticMessageRerequestFromPhone so undecryptable messages are re-requested from the phone and re-dispatched as normal Message events. Gated behind a new REREQUEST_FROM_PHONE env var (opt-in, default off) so operators choose per deployment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6justgotme
force-pushed
the
fix/rerequest-from-phone
branch
from
August 4, 2026 01:58
ea392fc to
3f84b3c
Compare
Author
|
Thanks for the review — addressed both points and pushed as
|
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.
Problem
When a message can't be decrypted, whatsmeow emits
events.UndecryptableMessage. Inpkg/whatsmeow/service/whatsmeow.gothe handler for that event only forwards a webhook when it's aview_oncemessage (and reconnects for IDs starting with66/67). Every other undecryptable message is logged and dropped — no webhook, and nothing is done to recover it.Where this bites in practice is the first message from a brand-new contact. A new contact has no Signal session yet, so the first inbound message can fail to decrypt on the linked device; when it does, it's silently lost. The rest of the conversation decrypts fine once the session is established, so from the outside it looks like "the first message never arrives." Click-to-WhatsApp ad leads make this very visible, since every lead is a first-contact by definition.
Cause
Evolution Go runs as a companion/linked device, so it has no local history to fall back on. whatsmeow already handles this case: if the sender doesn't resend within
RequestFromPhoneDelay(~5s), it can re-request the message from the account's own phone (the primary device, which already decrypted it). That path is gated behindClient.AutomaticMessageRerequestFromPhone, and the service never enables it — so the fallback never runs and the message stays lost.Fix
Enable whatsmeow's
AutomaticMessageRerequestFromPhoneinStartClient, gated behind a newREREQUEST_FROM_PHONEenv var so it's opt-in per deployment (default off):With
REREQUEST_FROM_PHONE=true, an undecryptable message gets re-requested from the phone and comes back through as a normalevents.Message, so the webhook fires as expected.Notes
REREQUEST_FROM_PHONE=true.