Repository navigation
fix(query-core): wrap queueMicrotask in defaultScheduler - #12748
Conversation
Wrap queueMicrotask in a callback arrow function in defaultScheduler instead of exporting the global directly. Invoking a bare re-exported WebIDL queueMicrotask as a method throws TypeError: Illegal invocation, and capturing the reference at module load prevents spying on globalThis.queueMicrotask. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 7e5cd61 The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
View your CI Pipeline Execution ↗ for commit 7e5cd61
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview23 package(s) bumped directly, 2 bumped as dependents. 🟥 Major bumps
|
size-limit report 📦
|
🎯 Changes
Follow-up to #12662 for TanStack Query v6.
packages/query-core/src/notifyManager.tsexporteddefaultScheduleras a direct reference toqueueMicrotask:Because
queueMicrotaskis a WebIDL method on the global object, calling it as a method on a namespace or object (mod.defaultScheduler(cb)) throwsTypeError: Illegal invocationin browsers. Capturing the reference at module load time also prevents tests from spying onglobalThis.queueMicrotaskafter import.This PR wraps the call in an arrow function matching the other void callbacks in
notifyManager.ts:Regression tests in
packages/query-core/src/__tests__/notifyManager.test.tsxcover both namespace method invocation (with a WebIDL receiver check) and post-importvi.spyOn(globalThis, 'queueMicrotask')interception fordefaultSchedulerandnotifyManager.Local validation:
oxfmt --check,nx run-many --projects=@tanstack/query-core --targets=test:lib,test:types,test:oxlint,build,test:build,nx run-many --projects=@tanstack/react-query,@tanstack/preact-query,@tanstack/query-persist-client-core --targets=test:lib,nx run @tanstack/react-query:build,size-limit,pnpm run test:sherif,pnpm run test:knip, andpnpm run test:docsall passed. Full monorepopnpm run test:prwas not run locally becausequery-v6diverges frommain.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact