You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The shared vitest setup wraps setTimeout so leaked timers can be cleared in afterEach, but setInterval was untracked. @formkit/auto-animate registers a setInterval in poll() (index.mjs:161) that polls every two seconds and calls requestAnimationFrame inside lowPriority. After the test file finished and jsdom was torn down, that interval kept firing and tripped on the missing requestAnimationFrame global, which is what was failing the Unit Tests check on #8548 even though all 1833 tests passed.
This wraps setInterval/clearInterval the same way as setTimeout and clears tracked intervals in afterEach.
Verified locally: pnpm --filter @clerk/ui run test and pnpm --filter @clerk/clerk-js run test both pass with no unhandled errors.
Auto-animate registers a setInterval in poll() that survived the existing
setTimeout-only cleanup. Once jsdom tore down, the interval fired and
referenced the now-missing requestAnimationFrame, producing 'Vitest caught
1 unhandled error' even though every test passed. Wrapping setInterval
the same way as setTimeout clears the leak.
Reviewing files that changed from the base of the PR and between 4ff81b6 and 999e171.
📒 Files selected for processing (2)
.changeset/clear-tracked-test-intervals.md
packages/clerk-js/vitest.setup.mts
📝 Walkthrough
Walkthrough
This PR adds interval tracking to the vitest test setup file, mirroring existing setTimeout tracking behavior. A new activeIntervals set captures interval IDs created during tests, while wrapping global.setInterval and global.clearInterval to register and unregister those IDs. Test lifecycle hooks clear the set in beforeEach and explicitly cancel remaining intervals in afterEach. A corresponding changeset entry documents the infrastructure change.
The title accurately describes the main change: wrapping setInterval timers in the clerk-js vitest setup to clear them between tests, which is precisely what the changeset implements.
Description check
✅ Passed
The description provides clear context about the issue (untracked setInterval causing test failures), the root cause (@formkit/auto-animate registering intervals), and explains the solution with verification steps.
Docstring Coverage
✅ Passed
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
Comment @coderabbitai help to get the list of available commands and usage tips.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The shared vitest setup wraps setTimeout so leaked timers can be cleared in afterEach, but setInterval was untracked. @formkit/auto-animate registers a setInterval in poll() (index.mjs:161) that polls every two seconds and calls requestAnimationFrame inside lowPriority. After the test file finished and jsdom was torn down, that interval kept firing and tripped on the missing requestAnimationFrame global, which is what was failing the Unit Tests check on #8548 even though all 1833 tests passed.
This wraps setInterval/clearInterval the same way as setTimeout and clears tracked intervals in afterEach.
Verified locally: pnpm --filter @clerk/ui run test and pnpm --filter @clerk/clerk-js run test both pass with no unhandled errors.