惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Jina AI
Jina AI
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
Recent Announcements
Recent Announcements
I
InfoQ
L
LangChain Blog
The Cloudflare Blog
IT之家
IT之家
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
博客园 - 聂微东
美团技术团队
博客园_首页

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
Fix Telegram isolated polling stall watchdog (#84861) · o...
joshavant · 2026-05-21 · via Recent Commits to openclaw:main

@@ -3,6 +3,7 @@ import os from "node:os";

33

import path from "node:path";

44

import type { ChannelAccountSnapshot } from "openclaw/plugin-sdk/channel-contract";

55

import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

6+

import type { TelegramIngressWorkerMessage } from "./telegram-ingress-worker.js";

6778

const runMock = vi.hoisted(() => vi.fn());

89

const createTelegramBotMock = vi.hoisted(() => vi.fn());

@@ -90,6 +91,7 @@ type WorkerPollErrorListener = (message: {

9091

message: string;

9192

finishedAt: number;

9293

}) => void;

94+

type WorkerMessageListener = (message: TelegramIngressWorkerMessage) => void;

9395

type AsyncVoidFn = () => Promise<void>;

9496

type MockCallSource = { mock: { calls: Array<Array<unknown>> } };

9597

@@ -176,6 +178,7 @@ function installPollingStallWatchdogHarness(dateNowSequence: readonly number[] =

176178

break;

177179

}

178180

await Promise.resolve();

181+

await new Promise<void>((resolve) => setImmediate(resolve));

179182

}

180183

expect(watchdog).toBeTypeOf("function");

181184

return watchdog;

@@ -776,6 +779,142 @@ describe("TelegramPollingSession", () => {

776779

await runPromise;

777780

});

778781782+

it("restarts isolated ingress when worker liveness stalls", async () => {

783+

const abort = new AbortController();

784+

const log = vi.fn();

785+

const bot = {

786+

api: {

787+

deleteWebhook: vi.fn(async () => true),

788+

config: { use: vi.fn() },

789+

},

790+

init: vi.fn(async () => undefined),

791+

handleUpdate: vi.fn(async () => undefined),

792+

stop: vi.fn(async () => undefined),

793+

};

794+

createTelegramBotMock.mockReturnValue(bot);

795+796+

let firstWorkerDone: (() => void) | undefined;

797+

const firstWorkerTask = new Promise<void>((resolve) => {

798+

firstWorkerDone = resolve;

799+

});

800+

const firstWorkerStop = vi.fn(async () => {

801+

firstWorkerDone?.();

802+

});

803+

let workerCycle = 0;

804+

const createWorker = vi.fn(() => {

805+

workerCycle += 1;

806+

if (workerCycle === 1) {

807+

return {

808+

onMessage: vi.fn(() => () => undefined),

809+

stop: firstWorkerStop,

810+

task: vi.fn(async () => {

811+

await firstWorkerTask;

812+

}),

813+

};

814+

}

815+

return {

816+

onMessage: vi.fn(() => () => undefined),

817+

stop: vi.fn(async () => undefined),

818+

task: vi.fn(async () => {

819+

abort.abort();

820+

}),

821+

};

822+

});

823+

const watchdogHarness = installPollingStallWatchdogHarness([0]);

824+

const session = createPollingSession({

825+

abortSignal: abort.signal,

826+

log,

827+

stallThresholdMs: 30_000,

828+

isolatedIngress: {

829+

enabled: true,

830+

createWorker,

831+

drainIntervalMs: 500,

832+

},

833+

});

834+835+

try {

836+

const runPromise = session.runUntilAbort();

837+

const watchdog = await watchdogHarness.waitForWatchdog();

838+

watchdogHarness.setNow(31_000);

839+

watchdog?.();

840+841+

await vi.waitFor(() => expect(firstWorkerStop).toHaveBeenCalledTimes(1));

842+

await vi.waitFor(() => expect(createWorker).toHaveBeenCalledTimes(2));

843+

await runPromise;

844+845+

expectLogIncludes(log, "Polling stall detected");

846+

expectLogIncludes(log, "isolated polling ingress finished reason=polling stall detected");

847+

} finally {

848+

watchdogHarness.restore();

849+

abort.abort();

850+

}

851+

});

852+853+

it("keeps isolated ingress alive when spooled messages show worker activity", async () => {

854+

const abort = new AbortController();

855+

const log = vi.fn();

856+

const bot = {

857+

api: {

858+

deleteWebhook: vi.fn(async () => true),

859+

config: { use: vi.fn() },

860+

},

861+

init: vi.fn(async () => undefined),

862+

handleUpdate: vi.fn(async () => undefined),

863+

stop: vi.fn(async () => undefined),

864+

};

865+

createTelegramBotMock.mockReturnValue(bot);

866+867+

let onMessage: WorkerMessageListener | undefined;

868+

let stopWorker: (() => void) | undefined;

869+

const workerDone = new Promise<void>((resolve) => {

870+

stopWorker = resolve;

871+

});

872+

const workerStop = vi.fn(async () => {

873+

stopWorker?.();

874+

});

875+

const createWorker = vi.fn(() => ({

876+

onMessage: vi.fn((handler: WorkerMessageListener) => {

877+

onMessage = handler;

878+

return () => undefined;

879+

}),

880+

stop: workerStop,

881+

task: vi.fn(async () => {

882+

await workerDone;

883+

}),

884+

}));

885+

const watchdogHarness = installPollingStallWatchdogHarness([0]);

886+

const session = createPollingSession({

887+

abortSignal: abort.signal,

888+

log,

889+

stallThresholdMs: 30_000,

890+

isolatedIngress: {

891+

enabled: true,

892+

createWorker,

893+

drainIntervalMs: 500,

894+

},

895+

});

896+897+

try {

898+

const runPromise = session.runUntilAbort();

899+

const watchdog = await watchdogHarness.waitForWatchdog();

900+

onMessage?.({ type: "poll-start", offset: null, startedAt: 0 });

901+

watchdogHarness.setNow(31_000);

902+

onMessage?.({ type: "spooled", updateId: 42, queued: 1 });

903+

watchdogHarness.setNow(45_000);

904+

watchdog?.();

905+906+

expect(workerStop).not.toHaveBeenCalled();

907+

expectLogExcludes(log, "Polling stall detected");

908+909+

abort.abort();

910+

stopWorker?.();

911+

await runPromise;

912+

} finally {

913+

watchdogHarness.restore();

914+

abort.abort();

915+

}

916+

});

917+779918

it("keeps failed lanes blocked for the rest of the drain pass", async () => {

780919

await withTempSpool(async (tempDir) => {

781920

const abort = new AbortController();