Skip to content

fix(whatsapp): recover group inbound after reconnect churn#73732

Merged
vincentkoc merged 5 commits into
mainfrom
clownfish/ghcrawl-156581-autonomous-smoke
Apr 29, 2026
Merged

fix(whatsapp): recover group inbound after reconnect churn#73732
vincentkoc merged 5 commits into
mainfrom
clownfish/ghcrawl-156581-autonomous-smoke

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • add focused regression coverage for WhatsApp group inbound delivery after repeated 408 reconnect cycles
  • repair group metadata/hydration or socket wiring so group inbound recovers without a full gateway restart
  • keep the patch scoped to the WhatsApp plugin reliability path

Context

Canonical issue: #66920. Related evidence: #7433, #63855, #70856.

This does not replace the separate QR-pairing report #46518, the QR retry PR #47710, the timeout-config PR #63939, or the broader gateway wedge report #67986.

Validation

  • pnpm check:changed

Credit

Thanks to legonhilltech-jpg, octopuslabs-fl, Kanorin-chan, and stuswan for the reports and reproduction details.

ProjectClownfish replacement details:

@vincentkoc vincentkoc added clownfish:human-review clawsweeper Tracked by ClawSweeper automation labels Apr 28, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: S maintainer Maintainer-authored PR and removed clawsweeper Tracked by ClawSweeper automation labels Apr 28, 2026
@greptile-apps

greptile-apps Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a shared groupMetadataCache (Map<string, GroupMetadata>) that persists hydrated Baileys group metadata across reconnect cycles. On each connection, groupFetchAllParticipating populates the cache; if a subsequent sock.groupMetadata(jid) call fails during reconnect churn (e.g., 408), the code falls back to the persisted entry rather than returning empty metadata. The cache is also wired into the Baileys socket via cachedGroupMetadata so the protocol layer can skip redundant fetches on reconnect. A focused regression test validates the end-to-end recovery path.

Confidence Score: 5/5

Safe to merge — the change is well-scoped, consistent across all call sites, and backed by a targeted regression test.

No logic bugs found. The shared cache is threaded correctly through monitorWebInbox, attachWebInboxToSocket, WhatsAppConnectionController, and auto-reply/monitor.ts. The stale-fallback TTL behaviour is consistent with the existing cache design. No security or data-integrity concerns were identified.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(whatsapp): recover group inbound aft..." | Re-trigger Greptile

@clawsweeper

clawsweeper Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Keep open. This is a maintainer-owned PR with the protected maintainer label, and current main still does not contain the PR's shared WhatsApp group metadata fallback or shorter post-reconnect app-silence recovery behavior. The latest PR context says the earlier cache growth concern was addressed on the branch, so the right next step is maintainer review/landing rather than cleanup closure.

Maintainer follow-up before merge:

Keep this PR open for explicit maintainer review. If the bounded-cache and stale-data tradeoff is acceptable and CI/Testbox proof remains current, land the WhatsApp plugin recovery patch with its focused regression coverage, then close the canonical WhatsApp group inbound issue after merge.

Best possible solution:

Keep this PR open for explicit maintainer review. If the bounded-cache and stale-data tradeoff is acceptable and CI/Testbox proof remains current, land the WhatsApp plugin recovery patch with its focused regression coverage, then close the canonical WhatsApp group inbound issue after merge.

What I checked:

Likely related people:

  • vincentkoc: Repository member, self-assigned on the PR timeline, authored the current PR head, and posted the maintainer follow-up explaining the bounded-cache response to Aisle/ClawSweeper review. This routes the active branch review even though it is not proof of current-main authorship. (role: active maintainer / PR owner; confidence: high; commits: e2738bfeb24a, 2b40dc3a2d55; files: extensions/whatsapp/src/inbound/monitor.ts, extensions/whatsapp/src/connection-controller.ts, extensions/whatsapp/src/auto-reply/monitor.ts)
  • Peter Steinberger: Available current-main blame and log for the relevant WhatsApp monitor/controller/test/docs files point to Peter's recent commit beb1d9b touching the central paths, and current HEAD is also authored by Peter. This is the best current-main routing signal from local history. (role: recent current-main maintainer / adjacent owner; confidence: medium; commits: beb1d9b4815d, 48683a7f71b0; files: extensions/whatsapp/src/inbound/monitor.ts, extensions/whatsapp/src/connection-controller.ts, extensions/whatsapp/src/auto-reply/monitor.ts)

Remaining risk / open question:

  • Cleanup policy should not auto-close maintainer-owned or protected-label PRs.
  • Current main still lacks the PR's core WhatsApp reconnect recovery behavior, so closing now would discard an active fix candidate for WhatsApp group inbound messages silently drop after repeated 408 reconnect cycles (DMs survive) #66920 and related reports.
  • The branch's cache growth concern appears addressed by TTL, summarized entries, and a 500 entry cap, but cached group metadata can still be stale within the TTL; that tradeoff belongs in normal maintainer review.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 1c45592e620e.

@vincentkoc vincentkoc added clawsweeper Tracked by ClawSweeper automation and removed clownfish:merge-ready labels Apr 28, 2026
@openclaw-clownfish
openclaw-clownfish Bot force-pushed the clownfish/ghcrawl-156581-autonomous-smoke branch from 288c98d to dc14579 Compare April 29, 2026 00:26
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Apr 29, 2026
@openclaw-clownfish
openclaw-clownfish Bot force-pushed the clownfish/ghcrawl-156581-autonomous-smoke branch from dc14579 to dabe0e7 Compare April 29, 2026 00:27
@vincentkoc vincentkoc self-assigned this Apr 29, 2026
@vincentkoc
vincentkoc force-pushed the clownfish/ghcrawl-156581-autonomous-smoke branch from dabe0e7 to 2b40dc3 Compare April 29, 2026 10:03
@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer follow-up:

  • Addressed the Aisle/Clawsweeper cache concern in 2b40dc3: the shared WhatsApp group metadata fallback now stores only summarized inbound fields, expires entries on the existing 5 minute metadata TTL, and evicts by recency at 500 entries.
  • Rebased onto current origin/main, resolving the watchdog conflict by preserving the newer transport-timeout path and keeping the shorter post-reconnect app-silence recovery window.
  • No inline review threads are open.

Testbox proof (tbx_01kqcapechhya4az5qe029xdds):

  • OPENCLAW_TESTBOX=1 pnpm docs:list
  • OPENCLAW_TESTBOX=1 pnpm test:serial extensions/whatsapp/src/monitor-inbox.streams-inbound-messages.test-support.ts extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/connection-controller.test.ts (69 files / 670 tests)
  • OPENCLAW_TESTBOX=1 pnpm check:changed

@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer follow-up after Aisle refresh:

  • Added dac1f92 to minimize the shared reconnect metadata cache: it now stores only group subject + TTL/LRU state, not full participant identifiers. Live per-message metadata behavior remains unchanged, but reconnect fallback no longer resurrects cached phone-number/member lists into inbound prompt context.
  • The same change removes eager participant resolution from groupFetchAllParticipating() hydration, so connect-time shared hydration no longer fans out over every group participant.
  • Added/kept regression coverage in 8d428d7.

Fresh Testbox proof on replacement box tbx_01kqcdbvs897xcgfgser05fdsc:

  • OPENCLAW_TESTBOX=1 pnpm test:serial extensions/whatsapp/src/monitor-inbox.streams-inbound-messages.test-support.ts extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/connection-controller.test.ts passed: WhatsApp e2e + extension shard, 69 files / 670 tests.
  • OPENCLAW_TESTBOX=1 pnpm check:changed passed.

Earlier box tbx_01kqcapechhya4az5qe029xdds was stopped after SSH sync failures (publickey/timeout) and replaced.

@vincentkoc
vincentkoc merged commit 21a92ea into main Apr 29, 2026
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web clawsweeper Tracked by ClawSweeper automation docs Improvements or additions to documentation maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant