test: make the timeout-wins race deterministic under fake timers
CI (node 24/26) failed on the exact-boundary construction: advanceTimersByTime(100) then an immediate upstream.abort() let the manual abort win the race on some runtimes, so timeoutOf returned undefined. Advance unambiguously past the deadline and assert the timeout classification before firing the late abort — that late abort is now asserted as a no-op, which is the real first-cause-wins invariant.
This commit is contained in:
parent
208123f252
commit
6beed9a883
1 changed files with 5 additions and 1 deletions
|
|
@ -99,7 +99,11 @@ describe('deadline — fuse with upstream', () => {
|
|||
try {
|
||||
const upstream = new AbortController()
|
||||
using d = deadline(upstream.signal, 100, 'WEB_FETCH_TIMEOUT')
|
||||
vi.advanceTimersByTime(100) // timer fires first
|
||||
vi.advanceTimersByTime(150) // past the 100ms deadline: the timer fires first
|
||||
expect(d.signal.aborted).toBe(true)
|
||||
expect(timeoutOf(d.signal)?.code).toBe('WEB_FETCH_TIMEOUT')
|
||||
// A later upstream abort is a no-op on the already-aborted fused signal:
|
||||
// AbortSignal.any keeps the FIRST cause, so the timeout classification stands.
|
||||
upstream.abort('too late')
|
||||
expect(timeoutOf(d.signal)?.code).toBe('WEB_FETCH_TIMEOUT')
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue