Repository navigation
test(fetch): restore real timers after "re-fetches after expiry" - #1074
sonukapoor wants to merge 1 commit into
Conversation
The test enabled fake timers and never switched back. Tests run with `isolate: false`, so a test file that runs next in the same worker inherits the fake timers; the filesystem tests then time out.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
The
re-fetches after expirytest inpackages/fetch/test/index.test.tscallsvitest.useFakeTimers()but never switches back to real timers.Because the Vitest config uses
isolate: false, the next test file that runs in the same worker inherits the fake timers. When that file ispackages/filesystem/test/index.test.ts, its 4 timer-based tests time out (4 × 5 s):Whether this happens depends on which worker picks up which file, so in a normal run it shows up only now and then. I ran into it while comparing test runs across environments.
Reproduce (runs both files in one worker, fetch first):
On
main, the 4 filesystem tests above fail withTest timed out in 5000ms. With this change, all 64 tests pass.Fix: call
vitest.useRealTimers()once the test no longer needs fake timers, the same way thewill abort the request on timeouttest in the same file already does.pnpm testpasses.No changeset, since only a test file changes.
Summary by CodeRabbit