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.
This commit is contained in:
parent
9688454a30
commit
043f094d07
@ -185,7 +185,14 @@ export async function waitForWaConnection(sock: ReturnType<typeof makeWASocket>)
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user