mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 00:23:29 +00:00
fix(gateway): distinguish disconnected from stuck in health-monitor restart reason
resolveChannelRestartReason did not handle the "disconnected" evaluation reason explicitly, so it fell through to "stuck". This conflates a clean WebSocket drop (e.g. Discord 1006) with a genuinely stuck channel, making logs misleading and preventing future policy differentiation. Add "disconnected" to ChannelRestartReason and handle it before the catch-all "stuck" return. Closes #36404
This commit is contained in:
committed by
Peter Steinberger
parent
0018f47661
commit
066d589b8a
@@ -234,4 +234,17 @@ describe("resolveChannelRestartReason", () => {
|
|||||||
);
|
);
|
||||||
expect(reason).toBe("gave-up");
|
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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export type ChannelHealthPolicy = {
|
|||||||
channelConnectGraceMs: number;
|
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 {
|
function isManagedAccount(snapshot: ChannelHealthSnapshot): boolean {
|
||||||
return snapshot.enabled !== false && snapshot.configured !== false;
|
return snapshot.enabled !== false && snapshot.configured !== false;
|
||||||
@@ -133,5 +133,8 @@ export function resolveChannelRestartReason(
|
|||||||
if (evaluation.reason === "not-running") {
|
if (evaluation.reason === "not-running") {
|
||||||
return snapshot.reconnectAttempts && snapshot.reconnectAttempts >= 10 ? "gave-up" : "stopped";
|
return snapshot.reconnectAttempts && snapshot.reconnectAttempts >= 10 ? "gave-up" : "stopped";
|
||||||
}
|
}
|
||||||
|
if (evaluation.reason === "disconnected") {
|
||||||
|
return "disconnected";
|
||||||
|
}
|
||||||
return "stuck";
|
return "stuck";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user