From 043f094d0785d403e1b7f29a2375698e52ecf60d Mon Sep 17 00:00:00 2001 From: rabsef-bicyrm Date: Tue, 27 Jan 2026 17:45:20 -0800 Subject: [PATCH] fix: WhatsApp 515 error retry not triggering due to shallow status extraction The WhatsApp QR login 515 auto-retry feature (added in 3b63d1cb) never triggered in production because getStatusCode() failed to extract the status code from Baileys' nested error structure. Baileys wraps errors in nested objects (err.lastDisconnect.error.output.statusCode), but getStatusCode() only checked err.output.statusCode. Meanwhile, formatError() correctly used extractBoomDetails() to check nested locations, which is why error messages displayed "status=515" even though login.errorStatus was undefined. This caused the retry check (login.errorStatus === 515) to always fail, so users experienced immediate login failures instead of automatic reconnection. Fix: Update getStatusCode() to use the same extractBoomDetails() logic as formatError(), ensuring it checks err.error and err.lastDisconnect.error for nested Boom-style status codes. --- src/web/session.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/web/session.ts b/src/web/session.ts index dcf0e253f..a9df964dc 100644 --- a/src/web/session.ts +++ b/src/web/session.ts @@ -185,7 +185,14 @@ export async function waitForWaConnection(sock: ReturnType) } export function getStatusCode(err: unknown) { + // Extract status from nested Baileys error structures (same as formatError) + const boom = + extractBoomDetails(err) ?? + extractBoomDetails((err as { error?: unknown })?.error) ?? + extractBoomDetails((err as { lastDisconnect?: { error?: unknown } })?.lastDisconnect?.error); + return ( + boom?.statusCode ?? (err as { output?: { statusCode?: number } })?.output?.statusCode ?? (err as { status?: number })?.status );