fix(whatsapp): wire missing Baileys retry/cache hooks for group message reliability#94338
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 21, 2026, 9:00 AM ET / 13:00 UTC. Summary PR surface: Source +473. Total +473 across 5 files. Reproducibility: yes. at source level: current main and v2026.6.9 omit the requested Baileys callbacks and group metadata listeners while Baileys v7.0.0-rc13 exposes and uses those hooks. I did not reproduce a live current-main decryption failure in this read-only review. Review metrics: 3 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the focused WhatsApp plugin fix after maintainers accept the bounded in-memory retention and residual retry-path proof gap, then let the linked issue close from the merged PR. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main and v2026.6.9 omit the requested Baileys callbacks and group metadata listeners while Baileys v7.0.0-rc13 exposes and uses those hooks. I did not reproduce a live current-main decryption failure in this read-only review. Is this the best way to solve the issue? Yes for the code boundary: the PR keeps the fix inside the WhatsApp plugin session/controller/inbound monitor path and avoids core API or config changes. The remaining question is how much direct retry-path proof maintainers want before merge. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8a7906c716d2. Label changesLabel justifications:
Evidence reviewedPR surface: Source +473. Total +473 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
CI note: the failing |
716b3db to
02c64d5
Compare
|
WhatsApp QA proof on local rewritten HEAD:
Post-run state:
Focused local checks still listed by the QA script for normal pre-merge coverage:
|
394a15f to
5a86f4b
Compare
Dependency graph guard clearedThis PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh
|
|
Merged via squash.
Thanks @xialonglee! |
Root Cause
WhatsApp/Baileys socket construction was missing required retry and cache hooks. When Baileys needs to decrypt a message or resolve group metadata during retry, it calls
getMessageandcachedGroupMetadatarespectively — both default toasync () => undefinedin Baileys. Without these callbacks, group message decryption can fail on retry, and group metadata is fetched on every use rather than served from cache. Additionally, four Baileys event handlers (groups.upsert,groups.update,group-participants.update,lid-mapping.update) were unregistered, leaving the metadata cache stale and group state untracked.Summary
getMessage,cachedGroupMetadata) were absent and cache-invalidation event handlers were unregistered.session.ts: Conditional spread forgetMessage/cachedGroupMetadatato avoid overriding Baileys defaults when not provided.inbound/monitor.ts: Bounded message store (500 entries) forgetMessageretry support; four event handlers (groups.upsert,groups.update,group-participants.update,lid-mapping.update) with proper close cleanup; initial group fetch populates the Baileys-level cache socachedGroupMetadataworks immediately for all pre-existing groups;groups.updateandgroup-participants.updatenow invalidate all three cache layers (baileysGroupMetaCache,groupMetaCache,groupMetadataCache) to prevent stale data after partial group updates; sent message content also cached inrecentMessageKeyssogetMessagecan return the originalproto.IMessageafter socket reconnect/cache-miss.connection-controller.ts: OptionalgetMessage/cachedGroupMetadataparameters passed through tocreateWaSocket.auto-reply/monitor.ts: Caches created and wired into the productionopenConnectioncall.Verification
node scripts/run-vitest.mjs extensions/whatsapp/src/monitor-inbox.behavior.test.ts— 75/75 passednode scripts/run-vitest.mjs extensions/whatsapp/src/connection-controller.test.ts— 17/17 passedReal behavior proof
Behavior addressed: WhatsApp group message decryption/retry reliability — missing Baileys getMessage and cachedGroupMetadata callbacks, unregistered group state event handlers, incomplete cache invalidation on group/participant updates, and unsent message content for getMessage retry after reconnect.
Real environment tested: Linux, Node 22, branch
fix/issue-7433-whatsapp-baileys-retry-hooks.Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: All WhatsApp tests pass (75/75 monitor-inbox, 17/17 connection-controller). The sent message caching ensures
getMessagereturns the originalproto.IMessagefor outbound messages after socket reconnect, matching the existing inbound message store pattern.What was not tested: Live WhatsApp E2E roundtrip (requires real WhatsApp credentials and a paired phone — no automated testing infrastructure available). Test coverage uses mocked Baileys socket events. The bounded message store eviction (500 entries) and sent-message caching paths are covered by unit tests.