openclaw - 💡(How to fix) Fix [BUG] WhatsApp credentials (creds.json) corrupted every ~35 minutes during pre-key rotation [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#60136Fetched 2026-04-08 02:35:52
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Error Message

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)

Fix Action

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)

Code Example

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
RAW_BUFFERClick to expand / collapse

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

extent analysis

TL;DR

Implement atomic writes for WhatsApp credentials to prevent corruption during pre-key rotation.

Guidance

  • Review the WhatsApp credential storage logic to identify and fix the non-atomic write operation, ensuring that credentials are written to a temporary file and then renamed to prevent corruption.
  • Verify that the corruption interval matches the pre-key rotation cycle, and adjust the fix accordingly.
  • Consider implementing a retry mechanism for scheduled tasks that fail due to connection drops.
  • Monitor the system for rate limiting issues after implementing the fix, as the workaround resolved a similar issue by removing the forced 30-minute refresh task.

Example

// Pseudo-code example of atomic write
function writeCredentialsAtomically(creds) {
  const tempFile = 'creds.tmp';
  fs.writeFileSync(tempFile, JSON.stringify(creds));
  fs.renameSync(tempFile, 'creds.json');
}

Notes

The provided workaround has mitigated some issues, but a permanent fix requires addressing the root cause of the corruption. The example code snippet is a simplified illustration of atomic writes and may need to be adapted to the actual implementation.

Recommendation

Apply the workaround and implement atomic writes for WhatsApp credentials, as this addresses the root cause of the corruption and prevents intermittent connection failures.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

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

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING