fix(release): stabilize config restart QA · openclaw/openclaw@cc91ff0
steipete
·
2026-05-22
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import fsSync from "node:fs"; |
1 | 2 | import fs from "node:fs/promises"; |
2 | 3 | import os from "node:os"; |
3 | 4 | import path from "node:path"; |
@@ -763,6 +764,35 @@ describe("acquireSessionWriteLock", () => {
|
763 | 764 | } |
764 | 765 | }); |
765 | 766 | |
| 767 | +it("retries when a reported stale same-process lock disappears before recovery", async () => { |
| 768 | +await withTempSessionLockFile(async ({ sessionFile, lockPath }) => { |
| 769 | +await fs.writeFile( |
| 770 | +lockPath, |
| 771 | +JSON.stringify({ |
| 772 | +pid: process.pid, |
| 773 | +createdAt: new Date().toISOString(), |
| 774 | +starttime: FAKE_STARTTIME, |
| 775 | +}), |
| 776 | +"utf8", |
| 777 | +); |
| 778 | +let resolverCalls = 0; |
| 779 | +testing.setProcessStartTimeResolverForTest((pid) => { |
| 780 | +if (pid !== process.pid) { |
| 781 | +return null; |
| 782 | +} |
| 783 | +resolverCalls += 1; |
| 784 | +if (resolverCalls === 1) { |
| 785 | +fsSync.rmSync(lockPath, { force: true }); |
| 786 | +} |
| 787 | +return FAKE_STARTTIME; |
| 788 | +}); |
| 789 | + |
| 790 | +const lock = await acquireSessionWriteLock({ sessionFile, timeoutMs: 500 }); |
| 791 | +await lock.release(); |
| 792 | +expect(resolverCalls).toBeGreaterThan(0); |
| 793 | +}); |
| 794 | +}); |
| 795 | + |
766 | 796 | it("removes held locks on termination signals", async () => { |
767 | 797 | const signals = ["SIGINT", "SIGTERM", "SIGQUIT", "SIGABRT"] as const; |
768 | 798 | const originalKill = process.kill.bind(process); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。