mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:31:06 +00:00
fix: use transport activity for stale health
This commit is contained in:
@@ -590,6 +590,7 @@ describe("TelegramPollingSession", () => {
|
||||
connected: false,
|
||||
lastConnectedAt: null,
|
||||
lastEventAt: null,
|
||||
lastTransportActivityAt: null,
|
||||
});
|
||||
const connectedPatch = setStatus.mock.calls.find(
|
||||
([patch]) => (patch as Record<string, unknown>).connected === true,
|
||||
@@ -599,9 +600,11 @@ describe("TelegramPollingSession", () => {
|
||||
mode: "polling",
|
||||
lastConnectedAt: expect.any(Number),
|
||||
lastEventAt: expect.any(Number),
|
||||
lastTransportActivityAt: expect.any(Number),
|
||||
lastError: null,
|
||||
});
|
||||
expect(connectedPatch?.lastConnectedAt).toBe(connectedPatch?.lastEventAt);
|
||||
expect(connectedPatch?.lastTransportActivityAt).toBe(connectedPatch?.lastEventAt);
|
||||
|
||||
abort.abort();
|
||||
resolveFirstTask();
|
||||
@@ -681,6 +684,7 @@ describe("TelegramPollingSession", () => {
|
||||
mode: "polling",
|
||||
lastConnectedAt: null,
|
||||
lastEventAt: null,
|
||||
lastTransportActivityAt: null,
|
||||
});
|
||||
expect(disconnectedPatches[1]?.[0]).toEqual({
|
||||
mode: "polling",
|
||||
|
||||
@@ -15,12 +15,14 @@ describe("createTelegramPollingStatusPublisher", () => {
|
||||
connected: false,
|
||||
lastConnectedAt: null,
|
||||
lastEventAt: null,
|
||||
lastTransportActivityAt: null,
|
||||
});
|
||||
expect(setStatus).toHaveBeenNthCalledWith(2, {
|
||||
mode: "polling",
|
||||
connected: true,
|
||||
lastConnectedAt: 1234,
|
||||
lastEventAt: 1234,
|
||||
lastTransportActivityAt: 1234,
|
||||
lastError: null,
|
||||
});
|
||||
expect(setStatus).toHaveBeenNthCalledWith(3, {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { ChannelAccountSnapshot } from "openclaw/plugin-sdk/channel-contract";
|
||||
import { createConnectedChannelStatusPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
||||
import {
|
||||
createConnectedChannelStatusPatch,
|
||||
createTransportActivityStatusPatch,
|
||||
} from "openclaw/plugin-sdk/gateway-runtime";
|
||||
|
||||
type TelegramPollingStatusSink = (patch: Omit<ChannelAccountSnapshot, "accountId">) => void;
|
||||
|
||||
@@ -11,11 +14,15 @@ export function createTelegramPollingStatusPublisher(setStatus?: TelegramPolling
|
||||
connected: false,
|
||||
lastConnectedAt: null,
|
||||
lastEventAt: null,
|
||||
lastTransportActivityAt: null,
|
||||
});
|
||||
},
|
||||
notePollSuccess(at = Date.now()) {
|
||||
setStatus?.({
|
||||
...createConnectedChannelStatusPatch(at),
|
||||
// A successful getUpdates call proves the Telegram HTTP long-poll is alive
|
||||
// even when the response has no user-visible updates.
|
||||
...createTransportActivityStatusPatch(at),
|
||||
mode: "polling",
|
||||
lastError: null,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user