Bug type
Behavior bug (incorrect output/state without crash)
Summary
WhatsApp QR pairing fails 100% of the time on Baileys v7 — 515 restart signal is never detected
Channel: whatsapp-web
Severity: Critical (complete feature breakage)
Description
WhatsApp QR pairing always fails with "WhatsApp login failed: status=515 Unknown Stream Errored (restart required)". The 515 "restart required" signal that Baileys sends during the key exchange is never detected, so the reconnect-with-saved-creds path (restartLoginSocket) is dead code.
Root Cause
getStatusCode() in src/web/session.ts receives a wrapper object { error: BoomError, date } from lastDisconnect, but only checks err.output?.statusCode and err.status — it never unwraps the .error property. This means login.errorStatus is always undefined when a 515 is received, the === 515 check never matches, and restartLoginSocket is never called.
Additionally, restartLoginSocket creates a new socket immediately after closing the old one without waiting for pending credential writes to flush. Even if the 515 were detected, useMultiFileAuthState would read stale/empty creds.
Steps to Reproduce
- Configure a WhatsApp channel in OpenClaw
- Start QR login via
web.login.start
- Scan the QR code with WhatsApp on phone
Expected
After 515, socket restarts with saved creds, connection completes, "Linked!" message returned.
Actual
getStatusCode({ error: BoomError(515), date }) → undefined → 515 check never matches → restartLoginSocket never called → pairing fails → creds directory is empty on disk.
Environment
- Baileys:
@whiskeysockets/baileys v7.0.0-rc.9
- Runtime: Node v22
- OS: Debian Bookworm (Docker)
Proposed Fix
- Add
err.error?.output?.statusCode fallback to getStatusCode() so it unwraps the lastDisconnect wrapper
- Export
waitForCredsSaveQueue() from session.ts
restartLoginSocket awaits creds flush before creating the new socket
Files affected: src/web/session.ts, src/web/login-qr.ts, src/web/login-qr.test.ts
Steps to reproduce
- Configure a WhatsApp channel in OpenClaw
- Start QR login via
web.login.start
- Scan the QR code with WhatsApp on phone
- Observe pairing fails with
status=515 Unknown Stream Errored (restart required)
Expected behavior
After Baileys sends the 515 "restart required" signal, the socket restarts with saved credentials and the connection completes successfully.
Actual behavior
getStatusCode() fails to unwrap the lastDisconnect wrapper object { error: BoomError, date }, returning undefined instead of 515. The restart path never triggers, credentials are never saved, and pairing fails every time.
OpenClaw version
2026.3.2
Operating system
Debian 13
Install method
Docker
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
No response
Bug type
Behavior bug (incorrect output/state without crash)
Summary
WhatsApp QR pairing fails 100% of the time on Baileys v7 — 515 restart signal is never detected
Channel: whatsapp-web
Severity: Critical (complete feature breakage)
Description
WhatsApp QR pairing always fails with
"WhatsApp login failed: status=515 Unknown Stream Errored (restart required)". The 515 "restart required" signal that Baileys sends during the key exchange is never detected, so the reconnect-with-saved-creds path (restartLoginSocket) is dead code.Root Cause
getStatusCode()insrc/web/session.tsreceives a wrapper object{ error: BoomError, date }fromlastDisconnect, but only checkserr.output?.statusCodeanderr.status— it never unwraps the.errorproperty. This meanslogin.errorStatusis alwaysundefinedwhen a 515 is received, the=== 515check never matches, andrestartLoginSocketis never called.Additionally,
restartLoginSocketcreates a new socket immediately after closing the old one without waiting for pending credential writes to flush. Even if the 515 were detected,useMultiFileAuthStatewould read stale/empty creds.Steps to Reproduce
web.login.startExpected
After 515, socket restarts with saved creds, connection completes, "Linked!" message returned.
Actual
getStatusCode({ error: BoomError(515), date })→undefined→ 515 check never matches →restartLoginSocketnever called → pairing fails → creds directory is empty on disk.Environment
@whiskeysockets/baileysv7.0.0-rc.9Proposed Fix
err.error?.output?.statusCodefallback togetStatusCode()so it unwraps thelastDisconnectwrapperwaitForCredsSaveQueue()fromsession.tsrestartLoginSocketawaits creds flush before creating the new socketFiles affected:
src/web/session.ts,src/web/login-qr.ts,src/web/login-qr.test.tsSteps to reproduce
web.login.startstatus=515 Unknown Stream Errored (restart required)Expected behavior
After Baileys sends the 515 "restart required" signal, the socket restarts with saved credentials and the connection completes successfully.
Actual behavior
getStatusCode()fails to unwrap thelastDisconnectwrapper object{ error: BoomError, date }, returningundefinedinstead of515. The restart path never triggers, credentials are never saved, and pairing fails every time.OpenClaw version
2026.3.2
Operating system
Debian 13
Install method
Docker
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
No response