Skip to content

[Bug]: WhatsApp reconnect loop exits on initial connection failure (DNS/network errors) #13506

@luizlf

Description

@luizlf

Summary

When the WhatsApp Web listener encounters a DNS or network error (ENOTFOUND web.whatsapp.com) during the initial connection attempt in monitorWebChannel, the error escapes the reconnect loop entirely. The gateway process keeps running but the WhatsApp channel remains dead until a manual restart.

This is distinct from mid-session disconnects (which are handled by the existing reconnect/backoff logic). The bug is specifically that the first await listenerFactory() call in monitorWebChannel (src/web/auto-reply/monitor.ts) has no error handling — if it throws, the entire channel monitor exits.

Root Cause

In src/web/auto-reply/monitor.ts, the reconnect loop calls await listenerFactory() without a try/catch. When this initial call fails (e.g., DNS resolution error), the error propagates up and exits monitorWebChannel. The existing backoff/retry logic only kicks in for subsequent disconnects (via listener.onClose), not for failures during initial startup.

Environment

  • OpenClaw version: 2026.2.3 (confirmed), likely affects all versions
  • Node version: v25.2.1
  • OS: macOS Darwin 25.2.0 (arm64)
  • Channel: WhatsApp Web (Baileys)

Steps to Reproduce

  1. Start the OpenClaw gateway with WhatsApp Web configured
  2. Ensure DNS resolution for web.whatsapp.com fails during startup (e.g., disconnect network briefly, or poison DNS)
  3. Observe that the channel monitor exits and does not retry

Expected Behavior

Initial connection failures should be caught and retried using the same backoff/maxAttempts logic as reconnects after mid-session disconnects.

Actual Behavior

The channel monitor exits silently. Logs show:

{"error":"Error: getaddrinfo ENOTFOUND web.whatsapp.com"},"WebSocket error"

No reconnect attempt is made. The channel stays dead until manual openclaw gateway restart.

Log Evidence (production, 2026-02-05)

path: "opt/homebrew/lib/node_modules/openclaw/dist/web/session.js:117"
time: "2026-02-05T07:16:14.679Z"
{"error":"Error: getaddrinfo ENOTFOUND web.whatsapp.com"},"WebSocket error"

Channel remained dead from 07:16 UTC until manual restart at 13:06 UTC (~6 hours of downtime).

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions