Skip to content

fix(whatsapp): stop reconnecting quiet sockets#71466

Closed
vincentkoc wants to merge 1 commit intomainfrom
fix/whatsapp-quiet-socket-watchdog
Closed

fix(whatsapp): stop reconnecting quiet sockets#71466
vincentkoc wants to merge 1 commit intomainfrom
fix/whatsapp-quiet-socket-watchdog

Conversation

@vincentkoc
Copy link
Copy Markdown
Member

Summary

  • Problem: WhatsApp linked-device sessions were force-reconnected after 30 minutes with no inbound app messages, even when the socket was otherwise healthy.
  • Why it matters: quiet WhatsApp accounts hit noisy 499 reconnect cycles, missed-message windows, and credential-restore churn that looked like transport failure.
  • What changed: the extension-local inbound-message silence watchdog is disabled by default; explicit test/runtime tuning can still enable it.
  • What did NOT change (scope boundary): no Baileys auth storage, QR login, outbound delivery queue, or Gateway health-monitor policy changed.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: WhatsApp had an extension-local watchdog that used inbound app-message silence as a liveness signal (lastInboundAt ?? startedAt). Quiet linked-device sessions are normal, so this forced unnecessary 499 reconnects.
  • Missing detection / guardrail: coverage proved explicit watchdog behavior, but not the production default for a quiet session with no inbound messages.
  • Contributing context (if known): Gateway-level channel health has moved toward transport-backed liveness, but WhatsApp still had this older local app-message watchdog path.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts
  • Scenario the test should lock in: a quiet linked-device session remains on the same listener after 31 minutes when no explicit watchdog timeout override is set.
  • Why this is the smallest reliable guardrail: the bug is the monitor/controller default wiring, not Baileys network behavior.
  • Existing test that already covers this (if any): explicit watchdog reconnect tests still cover the opt-in timeout path.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

Quiet WhatsApp sessions no longer reconnect solely due to no inbound app messages. Actual disconnects and Gateway health state still drive recovery.

Diagram (if applicable)

Before:
quiet WhatsApp account -> 30m no inbound messages -> forced 499 reconnect

After:
quiet WhatsApp account -> no inbound messages -> remains connected unless transport/lifecycle closes

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS local worktree
  • Runtime/container: Node 22 / pnpm
  • Model/provider: N/A
  • Integration/channel (if any): WhatsApp Web
  • Relevant config (redacted): default WhatsApp monitor settings

Steps

  1. Start WhatsApp monitor with keepAlive enabled and no messageTimeoutMs override.
  2. Leave the linked-device session quiet for longer than 30 minutes.
  3. Observe whether a forced 499 reconnect is triggered solely by app-message silence.

Expected

  • No forced reconnect occurs from app-message silence alone.

Actual

  • Before this PR, the default 30-minute silence watchdog closed the connection with status 499.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: pnpm test extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/connection-controller.test.ts
  • Edge cases checked: default quiet-session behavior, explicit watchdog override still covered by existing reconnect tests, formatting/whitespace.
  • What you did not verify: pnpm check:changed; multiple other worktrees already had check:changed / test lanes running, so I avoided queuing another heavy gate.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: a genuinely stale but still-open WhatsApp socket may not be restarted by app-message silence alone.
    • Mitigation: reconnect still follows actual socket close/error paths, and Gateway health should use transport/lifecycle signals rather than ordinary inbound app messages.

@vincentkoc vincentkoc self-assigned this Apr 25, 2026
@vincentkoc vincentkoc added dedupe:parent Primary canonical item in dedupe cluster bug Something isn't working channel: whatsapp-web Channel integration: whatsapp-web labels Apr 25, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XS maintainer Maintainer-authored PR labels Apr 25, 2026
@vincentkoc
Copy link
Copy Markdown
Member Author

ProjectClownfish could not safely update this branch, so it opened a narrow replacement PR instead.

Replacement PR: #72145
Source PR: #71466
Contributor credit is preserved in the replacement PR body and changelog plan.

@vincentkoc vincentkoc closed this Apr 26, 2026
vincentkoc added a commit that referenced this pull request Apr 26, 2026
Fixes #70678.\n\nKeeps quiet but healthy WhatsApp linked-device sessions connected by tracking WhatsApp Web transport activity, while retaining a longer app-silence cap so frame activity cannot mask a stuck session forever. Also cleans up transport activity listeners on failed connection-open paths.\n\nCarries forward the focused #71466 approach and keeps #63939 as related configurable-timeout follow-up. Thanks @vincentkoc and @oromeis.\n\nValidation:\n- pnpm test:serial extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/connection-controller.test.ts\n- pnpm check:changed\n- codex review --base origin/main
steipete pushed a commit that referenced this pull request Apr 26, 2026
Fixes #70678.\n\nKeeps quiet but healthy WhatsApp linked-device sessions connected by tracking WhatsApp Web transport activity, while retaining a longer app-silence cap so frame activity cannot mask a stuck session forever. Also cleans up transport activity listeners on failed connection-open paths.\n\nCarries forward the focused #71466 approach and keeps #63939 as related configurable-timeout follow-up. Thanks @vincentkoc and @oromeis.\n\nValidation:\n- pnpm test:serial extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/connection-controller.test.ts\n- pnpm check:changed\n- codex review --base origin/main
ayesha-aziz123 pushed a commit to ayesha-aziz123/openclaw that referenced this pull request Apr 26, 2026
Fixes openclaw#70678.\n\nKeeps quiet but healthy WhatsApp linked-device sessions connected by tracking WhatsApp Web transport activity, while retaining a longer app-silence cap so frame activity cannot mask a stuck session forever. Also cleans up transport activity listeners on failed connection-open paths.\n\nCarries forward the focused openclaw#71466 approach and keeps openclaw#63939 as related configurable-timeout follow-up. Thanks @vincentkoc and @oromeis.\n\nValidation:\n- pnpm test:serial extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/connection-controller.test.ts\n- pnpm check:changed\n- codex review --base origin/main
bminicore pushed a commit to bminicore/openclaw-fork that referenced this pull request Apr 27, 2026
Fixes openclaw#70678.\n\nKeeps quiet but healthy WhatsApp linked-device sessions connected by tracking WhatsApp Web transport activity, while retaining a longer app-silence cap so frame activity cannot mask a stuck session forever. Also cleans up transport activity listeners on failed connection-open paths.\n\nCarries forward the focused openclaw#71466 approach and keeps openclaw#63939 as related configurable-timeout follow-up. Thanks @vincentkoc and @oromeis.\n\nValidation:\n- pnpm test:serial extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/connection-controller.test.ts\n- pnpm check:changed\n- codex review --base origin/main
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
Fixes openclaw#70678.\n\nKeeps quiet but healthy WhatsApp linked-device sessions connected by tracking WhatsApp Web transport activity, while retaining a longer app-silence cap so frame activity cannot mask a stuck session forever. Also cleans up transport activity listeners on failed connection-open paths.\n\nCarries forward the focused openclaw#71466 approach and keeps openclaw#63939 as related configurable-timeout follow-up. Thanks @vincentkoc and @oromeis.\n\nValidation:\n- pnpm test:serial extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/connection-controller.test.ts\n- pnpm check:changed\n- codex review --base origin/main
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Fixes openclaw#70678.\n\nKeeps quiet but healthy WhatsApp linked-device sessions connected by tracking WhatsApp Web transport activity, while retaining a longer app-silence cap so frame activity cannot mask a stuck session forever. Also cleans up transport activity listeners on failed connection-open paths.\n\nCarries forward the focused openclaw#71466 approach and keeps openclaw#63939 as related configurable-timeout follow-up. Thanks @vincentkoc and @oromeis.\n\nValidation:\n- pnpm test:serial extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts extensions/whatsapp/src/connection-controller.test.ts\n- pnpm check:changed\n- codex review --base origin/main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working channel: whatsapp-web Channel integration: whatsapp-web dedupe:parent Primary canonical item in dedupe cluster docs Improvements or additions to documentation maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WhatsApp channel force-reconnects every 30 minutes on quiet-device sessions

1 participant