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

推荐订阅源

D
DataBreaches.Net
F
Fortinet All Blogs
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
罗磊的独立博客
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
J
Java Code Geeks
T
The Blog of Author Tim Ferriss
U
Unit 42
N
Netflix TechBlog - Medium
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Proofpoint News Feed
G
Google Developers Blog
H
Help Net Security

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 hot reload polling restarts (#83410) · openc...
joshavant · 2026-05-18 · via Recent Commits to openclaw:main

@@ -80,6 +80,11 @@ type WorkerPollSuccessListener = (message: {

8080

count: number;

8181

finishedAt: number;

8282

}) => void;

83+

type WorkerPollErrorListener = (message: {

84+

type: "poll-error";

85+

message: string;

86+

finishedAt: number;

87+

}) => void;

8388

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

8489

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

8590

@@ -1480,6 +1485,192 @@ describe("TelegramPollingSession", () => {

14801485

}

14811486

});

148214871488+

it("restarts isolated ingress when the worker task rejects before shutdown", async () => {

1489+

vi.useFakeTimers({ shouldAdvanceTime: true });

1490+

const abort = new AbortController();

1491+

const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-telegram-spool-"));

1492+

const log = vi.fn();

1493+

const setStatus = vi.fn();

1494+

createTelegramBotMock.mockImplementation(() => ({

1495+

api: {

1496+

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

1497+

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

1498+

},

1499+

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

1500+

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

1501+

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

1502+

}));

1503+1504+

let workerTaskCalls = 0;

1505+

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

1506+

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

1507+

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

1508+

stopWorker = resolve;

1509+

});

1510+

return {

1511+

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

1512+

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

1513+

stopWorker?.();

1514+

}),

1515+

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

1516+

workerTaskCalls += 1;

1517+

if (workerTaskCalls === 1) {

1518+

throw new Error("worker crashed");

1519+

}

1520+

await workerDone;

1521+

}),

1522+

};

1523+

});

1524+1525+

try {

1526+

const session = createPollingSession({

1527+

abortSignal: abort.signal,

1528+

log,

1529+

setStatus,

1530+

isolatedIngress: {

1531+

enabled: true,

1532+

spoolDir: tempDir,

1533+

createWorker,

1534+

drainIntervalMs: 100,

1535+

},

1536+

});

1537+1538+

const runPromise = session.runUntilAbort();

1539+

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

1540+

expectLogIncludes(log, "isolated polling ingress failed: worker crashed");

1541+

expect(

1542+

statusPatches(setStatus).some(

1543+

(patch) => patch.connected === false && patch.lastError === "worker crashed",

1544+

),

1545+

).toBe(true);

1546+1547+

abort.abort();

1548+

await vi.advanceTimersByTimeAsync(20_000);

1549+

await runPromise;

1550+

} finally {

1551+

vi.useRealTimers();

1552+

await fs.rm(tempDir, { recursive: true, force: true });

1553+

}

1554+

});

1555+1556+

it("treats isolated ingress worker rejection after abort as clean shutdown", async () => {

1557+

vi.useFakeTimers({ shouldAdvanceTime: true });

1558+

const abort = new AbortController();

1559+

const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-telegram-spool-"));

1560+

const log = vi.fn();

1561+

createTelegramBotMock.mockImplementation(() => ({

1562+

api: {

1563+

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

1564+

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

1565+

},

1566+

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

1567+

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

1568+

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

1569+

}));

1570+1571+

let rejectWorker: ((err: Error) => void) | undefined;

1572+

const workerDone = new Promise<void>((_resolve, reject) => {

1573+

rejectWorker = reject;

1574+

});

1575+

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

1576+

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

1577+

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

1578+

rejectWorker?.(new Error("worker exited with code 1"));

1579+

}),

1580+

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

1581+

await workerDone;

1582+

}),

1583+

}));

1584+1585+

try {

1586+

const session = createPollingSession({

1587+

abortSignal: abort.signal,

1588+

log,

1589+

isolatedIngress: {

1590+

enabled: true,

1591+

spoolDir: tempDir,

1592+

createWorker,

1593+

drainIntervalMs: 100,

1594+

},

1595+

});

1596+1597+

const runPromise = session.runUntilAbort();

1598+

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

1599+

abort.abort();

1600+

await vi.advanceTimersByTimeAsync(20_000);

1601+

await runPromise;

1602+1603+

expect(createWorker).toHaveBeenCalledTimes(1);

1604+

expectLogExcludes(log, "isolated polling ingress failed");

1605+

} finally {

1606+

vi.useRealTimers();

1607+

await fs.rm(tempDir, { recursive: true, force: true });

1608+

}

1609+

});

1610+1611+

it("propagates fatal isolated ingress polling errors", async () => {

1612+

vi.useFakeTimers({ shouldAdvanceTime: true });

1613+

const abort = new AbortController();

1614+

const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-telegram-spool-"));

1615+

const log = vi.fn();

1616+

const setStatus = vi.fn();

1617+

isRecoverableTelegramNetworkErrorMock.mockReturnValue(false);

1618+

createTelegramBotMock.mockImplementation(() => ({

1619+

api: {

1620+

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

1621+

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

1622+

},

1623+

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

1624+

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

1625+

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

1626+

}));

1627+1628+

let listener: WorkerPollErrorListener | undefined;

1629+

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

1630+

onMessage: vi.fn((next: WorkerPollErrorListener) => {

1631+

listener = next;

1632+

return () => undefined;

1633+

}),

1634+

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

1635+

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

1636+

listener?.({

1637+

type: "poll-error",

1638+

message: "Unauthorized",

1639+

finishedAt: Date.now(),

1640+

});

1641+

throw new Error("Telegram ingress worker exited with code 1");

1642+

}),

1643+

}));

1644+1645+

try {

1646+

const session = createPollingSession({

1647+

abortSignal: abort.signal,

1648+

log,

1649+

setStatus,

1650+

isolatedIngress: {

1651+

enabled: true,

1652+

spoolDir: tempDir,

1653+

createWorker,

1654+

drainIntervalMs: 100,

1655+

},

1656+

});

1657+1658+

await expect(session.runUntilAbort()).rejects.toThrow("Unauthorized");

1659+1660+

expect(createWorker).toHaveBeenCalledTimes(1);

1661+

expectLogExcludes(log, "isolated polling ingress failed");

1662+

expect(

1663+

statusPatches(setStatus).some(

1664+

(patch) => patch.connected === false && patch.lastError === "Unauthorized",

1665+

),

1666+

).toBe(true);

1667+

} finally {

1668+

abort.abort();

1669+

vi.useRealTimers();

1670+

await fs.rm(tempDir, { recursive: true, force: true });

1671+

}

1672+

});

1673+14831674

it("keeps active spooled lanes blocked across account restarts", async () => {

14841675

vi.useFakeTimers({ shouldAdvanceTime: true });

14851676

const firstAbort = new AbortController();