Skip to content

test(fetch): restore real timers after "re-fetches after expiry" - #1074

Open
sonukapoor wants to merge 1 commit into
solidjs-community:mainfrom
sonukapoor:fix/fetch-test-restore-real-timers
Open

sonukapoor wants to merge 1 commit into
solidjs-community:mainfrom
sonukapoor:fix/fetch-test-restore-real-timers

Conversation

@sonukapoor

@sonukapoor sonukapoor commented Oct 14, 2026 •

Copy link
Copy Markdown

The re-fetches after expiry test in packages/fetch/test/index.test.ts calls vitest.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 is packages/filesystem/test/index.test.ts, its 4 timer-based tests time out (4 × 5 s):

  • createFileSystem (sync) relays file system errors > a deleted file stored in a signal throws an error
  • createFileSystem(makeWebAccessFileSystem) > fs.readFile returns the content
  • createFileSystem(makeWebAccessFileSystem) > fs.writeFile updates a readFile resource
  • createFileSystem(makeWebAccessFileSystem) > fs.rename updates a readdir resource

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):

pnpm vitest -c ./configs/vitest.config.ts run --pool=forks --poolOptions.forks.singleFork packages/fetch/test/index.test.ts packages/filesystem/test/index.test.ts

On main, the 4 filesystem tests above fail with Test 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 the will abort the request on timeout test in the same file already does. pnpm test passes.

No changeset, since only a test file changes.

Summary by CodeRabbit

  • Tests
    • Improved the cache-expiry test’s timer cleanup to help prevent interference with other tests.

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.
@changeset-bot

changeset-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4411e9c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66b67af4-7abb-4449-b97d-4141cca5abc1
📥 Commits

Reviewing files that changed from the base of the PR and between 9c81cd0 and 4411e9c.

📒 Files selected for processing: 1
  • packages/fetch/test/index.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The cache-expiry test now restores real timers after advancing the fake clock.

Changes: Cache expiry test

Layer / File(s) Summary
Restore real timers
packages/fetch/test/index.test.ts
The test calls vitest.useRealTimers() after advancing the fake clock.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 4411e

This change restores real timers after the cache-expiry test; no merge-blocking impact is indicated.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the test change and the specific timer behavior being corrected.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant