-
-
Notifications
You must be signed in to change notification settings - Fork 69.1k
WhatsApp session doesn't survive unclean shutdown / reboot — requires manual re-pair #3942
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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
- Have WhatsApp linked and working
- Hard-shutdown the host machine (e.g. power off at wall, or kernel panic)
- Machine reboots, LaunchAgent starts the gateway automatically
- 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:
- Detect persistent WhatsApp connection failures (repeated Bad MAC / status 440/515 errors)
- Auto-clear the corrupted session files (keep
creds.json, deletesession-*.json) - Auto-reconnect using the existing credentials, or if that fails, surface a QR code via the webchat/dashboard for re-pairing
- 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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Fields
Give feedbackNo fields configured for issues without a type.