health: gateway-only status and stable reconnect
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user