diff --git a/src/commands/health.ts b/src/commands/health.ts index e33103cb3..3ec351a9f 100644 --- a/src/commands/health.ts +++ b/src/commands/health.ts @@ -183,12 +183,8 @@ export async function healthCommand( method: "health", timeoutMs: opts.timeoutMs, }); - const fatal = - !summary.web.linked || - (summary.web.connect && !summary.web.connect.ok) || - (summary.telegram.configured && - summary.telegram.probe && - !summary.telegram.probe.ok); + // Gateway reachability defines success; provider issues are reported but not fatal here. + const fatal = false; if (opts.json) { runtime.log(JSON.stringify(summary, null, 2)); diff --git a/src/commands/status.ts b/src/commands/status.ts index 72d2f07ea..948fd1ab6 100644 --- a/src/commands/status.ts +++ b/src/commands/status.ts @@ -218,7 +218,7 @@ export async function statusCommand( runtime.log(` ${line}`); } if (health) { - runtime.log(info("WA connect: reported by gateway (no direct probe)")); + runtime.log(info("Gateway health: reachable")); const tgLine = health.telegram.configured ? health.telegram.probe?.ok diff --git a/src/web/auto-reply.ts b/src/web/auto-reply.ts index 2cb6a8f72..98c9b3a91 100644 --- a/src/web/auto-reply.ts +++ b/src/web/auto-reply.ts @@ -327,10 +327,10 @@ export async function runWebHeartbeatOnce(opts: { { to, reason: "heartbeat-token", rawLength: replyPayload.text?.length }, "heartbeat skipped", ); - console.log(success("heartbeat: ok (HEARTBEAT_OK)")); - emitHeartbeatEvent({ status: "ok-token", to }); - return; - } + console.log(success("heartbeat: ok (HEARTBEAT_OK)")); + emitHeartbeatEvent({ status: "ok-token", to }); + return; + } if (hasMedia) { heartbeatLogger.warn( @@ -369,8 +369,9 @@ export async function runWebHeartbeatOnce(opts: { ); console.log(success(`heartbeat: alert sent to ${to}`)); } catch (err) { - heartbeatLogger.warn({ to, error: String(err) }, "heartbeat failed"); - console.log(danger(`heartbeat: failed - ${String(err)}`)); + const reason = String(err); + heartbeatLogger.warn({ to, error: reason }, "heartbeat failed"); + console.log(danger(`heartbeat: failed - ${reason}`)); emitHeartbeatEvent({ status: "failed", to, reason: String(err) }); throw err; } @@ -1380,15 +1381,9 @@ export async function monitorWebProvider( reconnectAttempts, maxAttempts: reconnectPolicy.maxAttempts, }, - "web reconnect: max attempts reached", + "web reconnect: max attempts reached; continuing in degraded mode", ); - runtime.error( - danger( - `WhatsApp Web connection closed (status ${status}). Reached max retries (${reconnectPolicy.maxAttempts}); exiting so you can relink.`, - ), - ); - await closeListener(); - break; + reconnectAttempts = 0; } const delay = computeBackoff(reconnectPolicy, reconnectAttempts);