



























@@ -35,7 +35,7 @@ import {
3535resolveReconnectPolicy,
3636sleepWithAbort,
3737} from "../reconnect.js";
38-import { formatError, getWebAuthAgeMs, logoutWeb, readWebSelfId } from "../session.js";
38+import { formatError, getWebAuthAgeMs, readWebSelfId } from "../session.js";
3939import { resolveWhatsAppSocketTiming } from "../socket-timing.js";
4040import { getRuntimeConfig, getRuntimeConfigSourceSnapshot } from "./config.runtime.js";
4141import { whatsappHeartbeatLog, whatsappLog } from "./loggers.js";
@@ -142,43 +142,6 @@ function isRetryableAuthUnstableError(error: unknown): error is WhatsAppAuthUnst
142142);
143143}
144144145-async function clearTerminalWebAuthState(params: {
146-account: ReturnType<typeof resolveWhatsAppAccount>;
147-runtime: RuntimeEnv;
148-statusLabel: number | "unknown";
149-healthState: "logged-out" | "conflict";
150-log: ReturnType<typeof getChildLogger>;
151-}) {
152-try {
153-const cleared = await logoutWeb({
154-authDir: params.account.authDir,
155-isLegacyAuthDir: params.account.isLegacyAuthDir,
156-runtime: params.runtime,
157-});
158-params.log.warn(
159-{
160-accountId: params.account.accountId,
161- cleared,
162-healthState: params.healthState,
163-status: params.statusLabel,
164-},
165-"web reconnect: cleared cached auth after terminal close",
166-);
167-} catch (error) {
168-params.log.warn(
169-{
170-accountId: params.account.accountId,
171-error: formatError(error),
172-healthState: params.healthState,
173-status: params.statusLabel,
174-},
175-"web reconnect: failed clearing cached auth after terminal close",
176-);
177-params.runtime.error(
178-`WhatsApp Web cleanup failed after terminal close (status ${params.statusLabel}). Run \`${formatCliCommand("openclaw channels logout --channel whatsapp")}\`, then relink with \`${formatCliCommand("openclaw channels login --channel whatsapp")}\`.`,
179-);
180-}
181-}
182145const DEFAULT_TRANSPORT_TIMEOUT_MS = 5 * 60 * 1000;
183146184147export async function monitorWebChannel(
@@ -431,26 +394,12 @@ export async function monitorWebChannel(
431394"web reconnect: setup status error; max attempts reached",
432395);
433396if (setupDecision.healthState === "logged-out") {
434-await clearTerminalWebAuthState({
435- account,
436- runtime,
437-statusLabel: setupDecision.normalized.statusLabel,
438-healthState: setupDecision.healthState,
439-log: reconnectLogger,
440-});
441397runtime.error(
442398`WhatsApp session logged out during setup. Run \`${formatCliCommand("openclaw channels login --channel whatsapp")}\` to relink.`,
443399);
444400} else if (setupDecision.healthState === "conflict") {
445-await clearTerminalWebAuthState({
446- account,
447- runtime,
448-statusLabel: setupDecision.normalized.statusLabel,
449-healthState: setupDecision.healthState,
450-log: reconnectLogger,
451-});
452401runtime.error(
453-`WhatsApp Web connection closed during setup (status ${setupDecision.normalized.statusLabel}: session conflict). Resolve conflicting WhatsApp Web sessions, then relink with \`${formatCliCommand("openclaw channels login --channel whatsapp")}\`. Stopping web monitoring.`,
402+`WhatsApp Web connection closed during setup (status ${setupDecision.normalized.statusLabel}: session conflict). Resolve conflicting WhatsApp Web sessions, then restart the channel. To force a fresh QR, run \`${formatCliCommand("openclaw channels logout --channel whatsapp")}\` before \`${formatCliCommand("openclaw channels login --channel whatsapp")}\`. Stopping web monitoring.`,
454403);
455404} else {
456405runtime.error(
@@ -668,24 +617,10 @@ export async function monitorWebChannel(
668617});
669618670619if (decision.healthState === "logged-out") {
671-await clearTerminalWebAuthState({
672- account,
673- runtime,
674-statusLabel: decision.normalized.statusLabel,
675-healthState: decision.healthState,
676-log: reconnectLogger,
677-});
678620runtime.error(
679621`WhatsApp session logged out. Run \`${formatCliCommand("openclaw channels login --channel whatsapp")}\` to relink.`,
680622);
681623} else if (decision.healthState === "conflict") {
682-await clearTerminalWebAuthState({
683- account,
684- runtime,
685-statusLabel: decision.normalized.statusLabel,
686-healthState: decision.healthState,
687-log: reconnectLogger,
688-});
689624reconnectLogger.warn(
690625{
691626connectionId: connection.connectionId,
@@ -695,7 +630,7 @@ export async function monitorWebChannel(
695630"web reconnect: non-retryable close status; stopping monitor",
696631);
697632runtime.error(
698-`WhatsApp Web connection closed (status ${decision.normalized.statusLabel}: session conflict). Resolve conflicting WhatsApp Web sessions, then relink with \`${formatCliCommand("openclaw channels login --channel whatsapp")}\`. Stopping web monitoring.`,
633+`WhatsApp Web connection closed (status ${decision.normalized.statusLabel}: session conflict). Resolve conflicting WhatsApp Web sessions, then restart the channel. To force a fresh QR, run \`${formatCliCommand("openclaw channels logout --channel whatsapp")}\` before \`${formatCliCommand("openclaw channels login --channel whatsapp")}\`. Stopping web monitoring.`,
699634);
700635} else {
701636reconnectLogger.warn(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。