Skip to content

WhatsApp: Messages silently dropped during reconnection window #14827

@CyberSinister

Description

@CyberSinister

Problem

When a WhatsApp Web disconnect occurs (408/503), messages sent during the ~3-5 second reconnection window are silently dropped. The agent receives no error feedback and believes the message was delivered.

Observed behavior:

  • WhatsApp gateway disconnects (status 408)
  • Gateway reconnects automatically (~3-5 seconds)
  • Agent's reply is generated during this window
  • sendWithRetry in deliver-reply.ts tries 3 times with short backoffs (500ms/1s/1.5s = 3s total)
  • All retries fail with 'Connection Closed' because reconnection takes longer
  • onError callback in process-message.ts logs the error and swallows it
  • Agent continues as if message was sent successfully
  • User never receives the reply

Log evidence:

WhatsApp gateway disconnected (status 408)
WhatsApp gateway connected.
Failed sending web auto-reply to <jid>: Connection Closed

Related: #2983 (same root issue, closed as stale without fix)

Root Cause

Two issues in the delivery pipeline:

  1. src/web/auto-reply/deliver-reply.tssendWithRetry() maxAttempts=3 with linear backoff (500ms × attempt). Total retry window ~3s, but reconnection takes ~3-5s. Retries are exhausted before connection is restored.

  2. src/web/auto-reply/monitor/process-message.tsonError callback only logs the error. No re-queue, no delivery failure notification to the agent, no system event.

Suggested Fix

  1. Increase sendWithRetry attempts from 3→5 and backoff from 500*attempt1000*attempt ms (total window ~10s, covers reconnection)
  2. Surface delivery failures as system events so the agent knows the message wasn't delivered

Environment

  • OpenClaw v0.40.4
  • WhatsApp Web via Baileys
  • Ubuntu/Linux VPS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions