Skip to content

Commit 698222f

Browse files
cliffhallclaude
andcommitted
test(memory): widen the heartbeat ownership test's timing margins
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent b17b76a commit 698222f

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎src/memory/__tests__/file-lock.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,9 @@ describe("withFileLock", () => {
251251
});
252252

253253
it("stops refreshing a lock that was broken and re-taken while it ran (#5418)", async () => {
254-
// Heartbeat every 25 ms; the operation outlives several beats.
255-
const opts = { staleMs: 50, timeoutMs: 5_000, retryMs: 5 };
254+
// Heartbeat every 100 ms, wide enough that the replacement below finishes
255+
// before the next beat; the operation outlives several beats.
256+
const opts = { staleMs: 200, timeoutMs: 5_000, retryMs: 5 };
256257
const old = new Date(Date.now() - 60_000);
257258
const realUtimes = fs.utimes;
258259
let replaced!: () => void;
@@ -279,11 +280,11 @@ describe("withFileLock", () => {
279280
// Several heartbeats later, only the first one, on our own lock, has
280281
// touched the file: the next one read the new owner's token and stopped
281282
// the interval, so the beats after it do not even read the file.
282-
await new Promise((resolve) => setTimeout(resolve, 100));
283+
await new Promise((resolve) => setTimeout(resolve, 250));
283284
expect(utimes).toHaveBeenCalledTimes(1);
284285
const reads = lockReads();
285286
expect(reads).toBeGreaterThan(0);
286-
await new Promise((resolve) => setTimeout(resolve, 150));
287+
await new Promise((resolve) => setTimeout(resolve, 350));
287288
expect(lockReads()).toBe(reads);
288289
},
289290
opts,

0 commit comments

Comments
 (0)