mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 14:36:52 +00:00
fix(whatsapp): stop retry loop on non-retryable 440 close
This commit is contained in:
committed by
Peter Steinberger
parent
def993dbd8
commit
e22a2d77ba
@@ -31,6 +31,12 @@ import { createWebOnMessageHandler } from "./monitor/on-message.js";
|
||||
import type { WebChannelStatus, WebInboundMsg, WebMonitorTuning } from "./types.js";
|
||||
import { isLikelyWhatsAppCryptoError } from "./util.js";
|
||||
|
||||
function isNonRetryableWebCloseStatus(statusCode: unknown): boolean {
|
||||
// WhatsApp 440 = session conflict ("Unknown Stream Errored (conflict)").
|
||||
// This is persistent until the operator resolves the conflicting session.
|
||||
return statusCode === 440;
|
||||
}
|
||||
|
||||
export async function monitorWebChannel(
|
||||
verbose: boolean,
|
||||
listenerFactory: typeof monitorWebInbox | undefined = monitorWebInbox,
|
||||
@@ -402,6 +408,22 @@ export async function monitorWebChannel(
|
||||
break;
|
||||
}
|
||||
|
||||
if (isNonRetryableWebCloseStatus(statusCode)) {
|
||||
reconnectLogger.warn(
|
||||
{
|
||||
connectionId,
|
||||
status: statusCode,
|
||||
error: errorStr,
|
||||
},
|
||||
"web reconnect: non-retryable close status; stopping monitor",
|
||||
);
|
||||
runtime.error(
|
||||
`WhatsApp Web connection closed (status ${statusCode}: session conflict). Resolve conflicting WhatsApp Web sessions, then relink with \`${formatCliCommand("openclaw channels login --channel web")}\`. Stopping web monitoring.`,
|
||||
);
|
||||
await closeListener();
|
||||
break;
|
||||
}
|
||||
|
||||
reconnectAttempts += 1;
|
||||
status.reconnectAttempts = reconnectAttempts;
|
||||
emitStatus();
|
||||
|
||||
Reference in New Issue
Block a user