Skip to content

[BUG] WhatsApp credentials (creds.json) corrupted every ~35 minutes during pre-key rotation #60136

Description

@Oahspe-001

Describe the bug

WhatsApp Web credentials file (creds.json) gets corrupted approximately every 35 minutes, which coincides with WhatsApp's pre-key rotation cycle. The system automatically restores from backup, but this causes intermittent connection failures and breaks scheduled task notifications.

Environment

  • OpenClaw Version: 2026.4.1
  • Node.js: v22.22.2
  • OS: Linux (VPS, virtual disk /dev/vda3)
  • Channel: WhatsApp Web
  • Account: [REDACTED - Phone number removed for privacy]

Logs

12:39:08 WARN  restored corrupted WhatsApp creds.json from backup
13:14:08 WARN  restored corrupted WhatsApp creds.json from backup  
13:49:09 WARN  restored corrupted WhatsApp creds.json from backup

Corruption interval: ~35 minutes (matches pre-key rotation)

Impact

  • Scheduled cron jobs fail to send notifications (3 tasks affected)
  • Requires manual openclaw channels login to reconnect
  • Gateway status 499 disconnections

Expected behavior

Credentials should be written atomically (write to temp file, then rename) to prevent corruption during pre-key rotation.

Possible cause

Race condition or non-atomic write in WhatsApp credential storage logic. The corruption occurs during the pre-key rotation write operation.

Workaround

Deployed monitoring script with:

  • Auto-relogin on disconnect (every 2 min check)
  • Automatic credential backup (every 30 min)
  • Removed forced 30-min refresh (triggers rate limiting)

Additional context

After deploying the workaround, observed a secondary issue: WhatsApp gateway disconnects every ~60 seconds (status 499), possibly due to rate limiting from forced refresh. This was resolved by removing the 30-minute forced login task.


Reproduction steps:

  1. Link WhatsApp Web account: openclaw channels login --channel whatsapp --account default
  2. Wait ~35 minutes for pre-key rotation
  3. Check logs for restored corrupted WhatsApp creds.json from backup
  4. Observe connection drops and failed scheduled tasks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions