























@@ -11,13 +11,15 @@ import { getChildLogger } from "openclaw/plugin-sdk/runtime-env";
1111import {
1212defaultRuntime,
1313formatDurationPrecise,
14+warn,
1415type RuntimeEnv,
1516} from "openclaw/plugin-sdk/runtime-env";
1617import { enqueueSystemEvent } from "openclaw/plugin-sdk/system-event-runtime";
1718import { resolveWhatsAppAccount, resolveWhatsAppMediaMaxBytes } from "../accounts.js";
1819import { WHATSAPP_AUTH_UNSTABLE_CODE, WhatsAppAuthUnstableError } from "../auth-store.js";
1920import {
2021WhatsAppConnectionController,
22+WHATSAPP_WATCHDOG_TIMEOUT_ERROR,
2123type ManagedWhatsAppListener,
2224} from "../connection-controller.js";
2325import { attachWebInboxToSocket, type WhatsAppGroupMetadataCache } from "../inbound/monitor.js";
@@ -566,11 +568,14 @@ export async function monitorWebChannel(
566568break;
567569}
568570571+const isWatchdogRecoveryReconnect =
572+decision.normalized.error === WHATSAPP_WATCHDOG_TIMEOUT_ERROR;
569573statusController.noteClose({
570574statusCode: decision.normalized.statusCode,
571575error: decision.normalized.errorText,
572576reconnectAttempts: decision.reconnectAttempts,
573577healthState: decision.healthState,
578+watchdogRecovery: isWatchdogRecoveryReconnect,
574579});
575580reconnectLogger.info(
576581{
@@ -582,9 +587,14 @@ export async function monitorWebChannel(
582587},
583588"web reconnect: scheduling retry",
584589);
585-runtime.error(
586-`WhatsApp Web connection closed (status ${decision.normalized.statusLabel}). Retry ${decision.reconnectAttempts}/${reconnectPolicy.maxAttempts || "∞"} in ${formatDurationPrecise(decision.delayMs ?? 0)}… (${decision.normalized.errorText})`,
587-);
590+const reconnectMessage = isWatchdogRecoveryReconnect
591+ ? `WhatsApp Web watchdog is recovering a stale connection (status ${decision.normalized.statusLabel}). Retry ${decision.reconnectAttempts}/${reconnectPolicy.maxAttempts || "∞"} in ${formatDurationPrecise(decision.delayMs ?? 0)}.`
592+ : `WhatsApp Web connection closed (status ${decision.normalized.statusLabel}). Retry ${decision.reconnectAttempts}/${reconnectPolicy.maxAttempts || "∞"} in ${formatDurationPrecise(decision.delayMs ?? 0)}… (${decision.normalized.errorText})`;
593+if (isWatchdogRecoveryReconnect) {
594+runtime.log(warn(reconnectMessage));
595+} else {
596+runtime.error(reconnectMessage);
597+}
588598await controller.closeCurrentConnection();
589599try {
590600await controller.waitBeforeRetry(decision.delayMs ?? 0);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。