fix(telegram): handle ENOENT race in spool drain recovery rename · openclaw/openclaw@66bbcfd
SebTardif
·
2026-06-01
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -242,6 +242,37 @@ describe("Telegram ingress spool", () => {
|
242 | 242 | }); |
243 | 243 | }); |
244 | 244 | |
| 245 | +it("handles ENOENT race when processing file is removed before recovery rename", async () => { |
| 246 | +await withTempSpool(async (spoolDir) => { |
| 247 | +await writeTelegramSpooledUpdate({ |
| 248 | + spoolDir, |
| 249 | +update: { update_id: 45, message: { text: "vanishes" } }, |
| 250 | +}); |
| 251 | +const update = (await listTelegramSpooledUpdates({ spoolDir }))[0]; |
| 252 | +if (!update) { |
| 253 | +throw new Error("Expected a spooled update"); |
| 254 | +} |
| 255 | +const claimed = await claimTelegramSpooledUpdate(update); |
| 256 | +if (!claimed) { |
| 257 | +throw new Error("Expected a claimed update"); |
| 258 | +} |
| 259 | +let shouldRecoverCalls = 0; |
| 260 | +const recovered = await recoverStaleTelegramSpooledUpdateClaims({ |
| 261 | + spoolDir, |
| 262 | +staleMs: 0, |
| 263 | +shouldRecover: async () => { |
| 264 | +shouldRecoverCalls += 1; |
| 265 | +await fs.unlink(claimed.path); |
| 266 | +return true; |
| 267 | +}, |
| 268 | +}); |
| 269 | + |
| 270 | +expect(recovered).toBe(0); |
| 271 | +expect(shouldRecoverCalls).toBe(1); |
| 272 | +expect(await fs.readdir(spoolDir)).toEqual([]); |
| 273 | +}); |
| 274 | +}); |
| 275 | + |
245 | 276 | it("does not treat stale claims with reused pids as live-owned", () => { |
246 | 277 | const now = Date.now(); |
247 | 278 | expect( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。