Skip to content

WhatsApp session doesn't survive unclean shutdown / reboot — requires manual re-pair #3942

@benjamindell

Description

@benjamindell

Summary

After an unclean shutdown (hard power off) or reboot of the host machine, the WhatsApp connection fails to reconnect on gateway restart. The Signal Protocol encryption session keys become corrupted, requiring a full manual re-pair via clawdbot channels login.

Steps to Reproduce

  1. Have WhatsApp linked and working
  2. Hard-shutdown the host machine (e.g. power off at wall, or kernel panic)
  3. Machine reboots, LaunchAgent starts the gateway automatically
  4. WhatsApp fails to reconnect

Error Logs

Failed to decrypt message with any known session...
Session error: Error: Bad MAC
  at Object.verifyMAC (libsignal/src/crypto.js:87:15)
  at SessionCipher.doDecryptWhisperMessage (libsignal/src/session_cipher.js:250:16)

[whatsapp] Web connection closed (status 440). Retry 1/12 in 2.46s
  (status=440 Unknown Stream Errored (conflict))
WhatsApp login failed: status=515 Unknown Stream Errored (restart required)

Root Cause

The Baileys library's Signal Protocol session state files can become stale or corrupted when the process is killed mid-write during an unclean shutdown. The creds.json survives fine, but the encryption session state does not.

Current Workaround

Run clawdbot channels login from a terminal to re-pair WhatsApp.

Feature Request

Ideally the gateway should:

  1. Detect persistent WhatsApp connection failures (repeated Bad MAC / status 440/515 errors)
  2. Auto-clear the corrupted session files (keep creds.json, delete session-*.json)
  3. Auto-reconnect using the existing credentials, or if that fails, surface a QR code via the webchat/dashboard for re-pairing
  4. Notify the user that WhatsApp was re-paired automatically

This would make the gateway fully reboot-resilient without manual intervention.

Environment

  • Clawdbot version: 2026.1.24-3
  • OS: macOS 26.2 (arm64)
  • Node: v22.22.0
  • Service: LaunchAgent (RunAtLoad + KeepAlive)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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