Opus finding
maybeRestoreCredsFromBackup races with concurrent reads of creds.json
lowconcurrencylow
- src/web/auth-store.ts:51-79
Restoration uses copyFileSync directly to creds.json rather than write-and-rename, leaving a window where creds.json is partially written. If another process (e.g., the baileys runtime) reads creds.json mid-copy, it could see truncated content. Since this runs during webAuthExists, it is on a hot path during startup; concurrent processes touching the same auth dir could observe corruption. Likelihood is low under normal single-process usage but the recommended pattern is rename-after-write.
Recommendation
Copy backup to a temp path (e.g., creds.json.restore), chmod, then fsSync.renameSync over creds.json for an atomic swap.