diff --git a/src/gateway/channel-health-policy.test.ts b/src/gateway/channel-health-policy.test.ts index 1509bccc4ba..906ea559bde 100644 --- a/src/gateway/channel-health-policy.test.ts +++ b/src/gateway/channel-health-policy.test.ts @@ -234,4 +234,17 @@ describe("resolveChannelRestartReason", () => { ); expect(reason).toBe("gave-up"); }); + + it("maps disconnected to disconnected instead of stuck", () => { + const reason = resolveChannelRestartReason( + { + running: true, + connected: false, + enabled: true, + configured: true, + }, + { healthy: false, reason: "disconnected" }, + ); + expect(reason).toBe("disconnected"); + }); }); diff --git a/src/gateway/channel-health-policy.ts b/src/gateway/channel-health-policy.ts index b3bc74bfc4d..27d7cd1f7b2 100644 --- a/src/gateway/channel-health-policy.ts +++ b/src/gateway/channel-health-policy.ts @@ -36,7 +36,7 @@ export type ChannelHealthPolicy = { channelConnectGraceMs: number; }; -export type ChannelRestartReason = "gave-up" | "stopped" | "stale-socket" | "stuck"; +export type ChannelRestartReason = "gave-up" | "stopped" | "stale-socket" | "stuck" | "disconnected"; function isManagedAccount(snapshot: ChannelHealthSnapshot): boolean { return snapshot.enabled !== false && snapshot.configured !== false; @@ -133,5 +133,8 @@ export function resolveChannelRestartReason( if (evaluation.reason === "not-running") { return snapshot.reconnectAttempts && snapshot.reconnectAttempts >= 10 ? "gave-up" : "stopped"; } + if (evaluation.reason === "disconnected") { + return "disconnected"; + } return "stuck"; }