From 3920c444cbf9ae8bee39b8d50fa48e7963c17fe7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Mar 2026 00:27:40 +0000 Subject: [PATCH] test: tighten json file lock coverage --- src/infra/json-files.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/infra/json-files.test.ts b/src/infra/json-files.test.ts index d2d0fa600f5..309fd59ae8b 100644 --- a/src/infra/json-files.test.ts +++ b/src/infra/json-files.test.ts @@ -65,4 +65,24 @@ describe("json file helpers", () => { await expect(second).resolves.toBe("ok"); expect(events).toEqual(["first:start", "first:end", "second:start", "second:end"]); }); + + it("releases the async lock after synchronous throws", async () => { + const withLock = createAsyncLock(); + const events: string[] = []; + + const first = withLock(async () => { + events.push("first:start"); + throw new Error("sync boom"); + }); + + const second = withLock(async () => { + events.push("second:start"); + events.push("second:end"); + return "ok"; + }); + + await expect(first).rejects.toThrow("sync boom"); + await expect(second).resolves.toBe("ok"); + expect(events).toEqual(["first:start", "second:start", "second:end"]); + }); });