Repository navigation
test(memory): count heartbeat reads from the lock's replacement, not the operation's resume - #5638
Conversation
…the operation's resume "stops refreshing a lock that was broken and re-taken while it ran" cleared its read count once the operation resumed. On a slow runner the next heartbeat could read the lock before then, so clearing wiped the very read it was waiting for and the count stayed 0. The count is now cleared inside the mocked heartbeat, at the moment of the replacement, and the next beat's read is waited for with vi.waitFor instead of a fixed 250 ms sleep. Closes #5634 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
|
| Tools | Prompts | Resources | Resource templates | |
|---|---|---|---|---|
| Base | 9 | 0 | 1 | 0 |
| Head | 9 | 0 | 1 | 0 |
Updated by this run for 3a62984fae8823f9989c248a0b9773d3588721a4.
There was a problem hiding this comment.
🟡 Changes recommended
The test can erase the heartbeat’s final read with a late mock reset, causing a timeout despite correct lock behavior; move the reset before the replacement write.
1 open issue
What changed in this PR
This test-only PR addresses #5634 by adjusting how the memory server’s lock-heartbeat regression test observes ownership changes on slow runners. No server behavior changes.
Changes:
- Moves the read-count reset into the mocked heartbeat after lock replacement.
- Replaces a fixed 250 ms delay with
vi.waitFor, allowing up to five seconds for a heartbeat read. - Preserves the refresh and stopped-read assertions without adding retries.
| File | Description |
|---|---|
src/memory/__tests__/file-lock.test.ts |
Adjusts read counting and waiting in the lock-ownership heartbeat regression test. |
Review effort: Balanced
Review of #5638: the next heartbeat can read the replacement token while the second utimes is pending, and clearing after it would wipe that read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
Round 1 answered in 3a62984 (gate exit 0). The one finding was valid: the read count is now cleared before the replacement token is written, so a heartbeat read that lands while the second |

Closes #5634
Description
The memory test "stops refreshing a lock that was broken and re-taken while it ran (#5418)" failed on a slow runner, although the behavior it tests is correct. It cleared its count of lock-file reads once the operation resumed. On a loaded runner, the next heartbeat could read the lock before that point. Clearing then wiped the very read the test was waiting for, and the count stayed 0.
Two changes, both to the test:
vi.waitFor, up to 5 s, instead of a fixed 250 ms sleep. A slow runner only makes the test take longer.The assertions are unchanged: exactly one refresh, at least one read after the replacement, and no further reads in the next 350 ms. There is no retry.
Server Details
__tests__/file-lock.test.ts. No server code, so no changeset and no README change.Motivation and Context
#5634: it failed in
Coverage memory(run 44417378815, job 135201148642) on a PR that did not touchsrc/memory/.How Has This Been Tested?
file-lock.test.tspass.npm run local:gateexits 0.Breaking Changes
None.
Types of changes
Checklist
🤖 Generated with Claude Code