openclaw-whatsapp-idle-watchdog-patch

OpenClaw WhatsApp Idle Watchdog: Patch & Self-Healing

Problem: OpenClaw’s WhatsApp plugin has a 30-minute idle watchdog (MESSAGE_TIMEOUT_MS = 1800 * 1e3) that bounces the WebSocket connection when no messages arrive. This causes 499 reconnect churn every ~60 seconds during quiet periods — noisy logs, unnecessary connection cycling, but no message loss.

Root cause: The watchdog timer in channel.runtime-*.js checks every 60s if any message was received in the last 30 minutes. On idle personal WhatsApp, this triggers constantly. The tuning object in the plugin only passes statusSink and accountId — no timeout overrides. Config-based override not possible (Zod schema rejects unknown keys at channels.whatsapp).

Fix: Direct runtime patch at dist/channel.runtime-Cu2TxQlg.js lines 2531-2532:

  • 1800 * 1e3216e5 (6 hours)
  • 60 * 1e33e5 (5 minutes)

Self-healing: /opt/infra/openclaw-wa-patch.sh runs daily via cron (04:00 IST). Detects if patch was overwritten by an OpenClaw upgrade and re-applies automatically. Idempotent — exits silently when already patched. Restarts openclaw-gateway service only when re-patching.

Upstream path: OpenClaw adding messageTimeoutMs/watchdogCheckMs to the WhatsApp channel config schema would make the runtime patch unnecessary.