mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 03:10:22 +00:00
fix(gateway): skip stale-socket restarts for Telegram polling (openclaw#38405)
Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: ql-wade <262266039+ql-wade@users.noreply.github.com>
This commit is contained in:
@@ -167,6 +167,28 @@ describe("createReadinessChecker", () => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("keeps telegram long-polling channels ready without stale-socket classification", () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-03-06T12:00:00Z"));
|
||||
const startedAt = Date.now() - 31 * 60_000;
|
||||
const manager = createManager(
|
||||
snapshotWith({
|
||||
telegram: {
|
||||
running: true,
|
||||
connected: true,
|
||||
enabled: true,
|
||||
configured: true,
|
||||
lastStartAt: startedAt,
|
||||
lastEventAt: null,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const readiness = createReadinessChecker({ channelManager: manager, startedAt });
|
||||
expect(readiness()).toEqual({ ready: true, failing: [], uptimeMs: 1_860_000 });
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("caches readiness snapshots briefly to keep repeated probes cheap", () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-03-06T12:00:00Z"));
|
||||
|
||||
@@ -50,11 +50,6 @@ export function createReadinessChecker(deps: {
|
||||
|
||||
const snapshot = channelManager.getRuntimeSnapshot();
|
||||
const failing: string[] = [];
|
||||
const policy: ChannelHealthPolicy = {
|
||||
now,
|
||||
staleEventThresholdMs: DEFAULT_CHANNEL_STALE_EVENT_THRESHOLD_MS,
|
||||
channelConnectGraceMs: DEFAULT_CHANNEL_CONNECT_GRACE_MS,
|
||||
};
|
||||
|
||||
for (const [channelId, accounts] of Object.entries(snapshot.channelAccounts)) {
|
||||
if (!accounts) {
|
||||
@@ -64,6 +59,12 @@ export function createReadinessChecker(deps: {
|
||||
if (!accountSnapshot) {
|
||||
continue;
|
||||
}
|
||||
const policy: ChannelHealthPolicy = {
|
||||
now,
|
||||
staleEventThresholdMs: DEFAULT_CHANNEL_STALE_EVENT_THRESHOLD_MS,
|
||||
channelConnectGraceMs: DEFAULT_CHANNEL_CONNECT_GRACE_MS,
|
||||
channelId,
|
||||
};
|
||||
const health = evaluateChannelHealth(accountSnapshot, policy);
|
||||
if (!health.healthy && !shouldIgnoreReadinessFailure(accountSnapshot, health)) {
|
||||
failing.push(channelId);
|
||||
|
||||
Reference in New Issue
Block a user