From 53afb97437da20225756908b0de1f1d4de766724 Mon Sep 17 00:00:00 2001 From: cliffhall Date: Fri, 27 Nov 2026 03:48:52 -0500 Subject: [PATCH] test(memory): count a real Windows refusal of the lock put-back as a retry, not a failure The put-back test injected two EPERM refusals and asserted exactly three attempts, but on a real Windows host the third, real rename can be refused too while the third writer holds the lock open, and restoreLock retries it. Assert three as the floor. Closes #5683 Co-Authored-By: Claude Opus 5.5 Signed-off-by: cliffhall --- src/memory/__tests__/file-lock.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/memory/__tests__/file-lock.test.ts b/src/memory/__tests__/file-lock.test.ts index 90ca6b43b9..63b5fc719a 100644 --- a/src/memory/__tests__/file-lock.test.ts +++ b/src/memory/__tests__/file-lock.test.ts @@ -670,7 +670,11 @@ describe("withFileLock", () => { ).rejects.toThrow("Timed out"); const outcome = await thirdOutcome; - expect(restores()).toBe(3); + // The two injected refusals were retried and a third attempt went to + // the real rename. On a real Windows host that rename can itself be + // refused while the third writer has the lock open, and is retried + // again, so three is the floor, not the count (#5683). + expect(restores()).toBeGreaterThanOrEqual(3); expect(third).not.toHaveBeenCalled(); expect((outcome as Error).message).toContain("Timed out"); expect(await fs.readFile(lockPath, "utf-8")).toBe("successor");