Skip to content

Commit e37e9bb

Browse files
committed
fix(test): scale lock maxDelayMs ceiling with Windows tolerance
The 'should respect maxDelayMs' assertion capped elapsed at a fixed 500ms, but Windows timer overhead pushed a correctly-capped retry to ~824ms. Scale the ceiling with tolerantTimeout (2500ms on Windows) — still far below the ~3s an uncapped baseDelayMs 1000 x 3 would take, so it proves the cap held without flaking on the slow runner.
1 parent 8db7fd3 commit e37e9bb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

test/unit/process/lock.test.mts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import type { ProcessLockOptions } from '../../../src/process/lock-types'
2323
import { safeDelete } from '../../../src/fs/safe'
2424
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
2525

26+
import { tolerantTimeout } from '../../_shared/fleet/lib/timing.mts'
27+
2628
// process-lock lazily does `require('node:fs')` inside getFs(). The require'd
2729
// CommonJS module's properties are writable/configurable, unlike the ESM
2830
// namespace import. We grab the same module via createRequire and patch
@@ -242,8 +244,11 @@ describe.sequential('process/lock', () => {
242244
).rejects.toThrow()
243245

244246
const elapsed = Date.now() - startTime
245-
// Even with high baseDelayMs, should be capped by maxDelayMs
246-
expect(elapsed).toBeLessThan(500)
247+
// Even with high baseDelayMs, should be capped by maxDelayMs. The ceiling
248+
// is tolerance-scaled: without the cap, baseDelayMs 1000 x 3 retries would
249+
// be ~3s, so tolerantTimeout(500) (2500ms on Windows's 5x timer budget)
250+
// still proves the 50ms cap held while absorbing slow-runner overhead.
251+
expect(elapsed).toBeLessThan(tolerantTimeout(500))
247252

248253
release1()
249254
})

0 commit comments

Comments
 (0)