Skip to content

fix(query-core): wrap queueMicrotask in defaultScheduler - #12748

Merged
TkDodo merged 1 commit into
query-v6from
schiller-manuel-fix-query-v6-default-scheduler
Dec 4, 2026
Merged

TkDodo merged 1 commit into
query-v6from
schiller-manuel-fix-query-v6-default-scheduler

Conversation

@schiller-manuel

Copy link
Copy Markdown
Contributor

🎯 Changes

Follow-up to #12662 for TanStack Query v6.

packages/query-core/src/notifyManager.ts exported defaultScheduler as a direct reference to queueMicrotask:

export const defaultScheduler: ScheduleFunction = queueMicrotask

Because queueMicrotask is a WebIDL method on the global object, calling it as a method on a namespace or object (mod.defaultScheduler(cb)) throws TypeError: Illegal invocation in browsers. Capturing the reference at module load time also prevents tests from spying on globalThis.queueMicrotask after import.

This PR wraps the call in an arrow function matching the other void callbacks in notifyManager.ts:

export const defaultScheduler: ScheduleFunction = (callback) => {
  queueMicrotask(callback)
}

Regression tests in packages/query-core/src/__tests__/notifyManager.test.tsx cover both namespace method invocation (with a WebIDL receiver check) and post-import vi.spyOn(globalThis, 'queueMicrotask') interception for defaultScheduler and notifyManager.

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, and pnpm run test:docs all passed. Full monorepo pnpm run test:pr was not run locally because query-v6 diverges from main.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

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-bot

changeset-bot Bot commented Dec 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7e5cd61

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@tanstack/query-core Patch
@tanstack/angular-query Patch
@tanstack/lit-query Patch
@tanstack/preact-query Patch
@tanstack/query-async-storage-persister Patch
@tanstack/query-broadcast-client-experimental Patch
@tanstack/query-devtools Patch
@tanstack/query-persist-client-core Patch
@tanstack/react-query Patch
@tanstack/solid-query Patch
@tanstack/svelte-query Patch
@tanstack/vue-query Patch
@tanstack/angular-query-devtools Patch
@tanstack/angular-query-persist-client Patch
@tanstack/preact-query-devtools Patch
@tanstack/preact-query-persist-client Patch
@tanstack/react-query-devtools Patch
@tanstack/solid-query-devtools Patch
@tanstack/svelte-query-devtools Patch
@tanstack/vue-query-devtools Patch
@tanstack/react-query-persist-client Patch
@tanstack/solid-query-persist-client Patch
@tanstack/svelte-query-persist-client Patch
@tanstack/react-query-next-experimental Patch
@tanstack/eslint-plugin-query Patch

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

@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

@nx-cloud

nx-cloud Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 7e5cd61

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 8m 47s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 35s View ↗

☁️ Nx Cloud last updated this comment at 2026-12-04 18:02:50 UTC

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

23 package(s) bumped directly, 2 bumped as dependents.

🟥 Major bumps

Package Version Reason
@tanstack/angular-query 5.108.4 → 6.0.0 Changeset
@tanstack/angular-query-devtools 5.108.4 → 6.0.0 Changeset
@tanstack/eslint-plugin-query 5.108.4 → 6.0.0 Changeset
@tanstack/lit-query 0.2.44 → 1.0.0 Changeset
@tanstack/preact-query 5.108.4 → 6.0.0 Changeset
@tanstack/preact-query-devtools 5.108.4 → 6.0.0 Changeset
@tanstack/preact-query-persist-client 5.108.4 → 6.0.0 Changeset
@tanstack/query-async-storage-persister 5.108.4 → 6.0.0 Changeset
@tanstack/query-broadcast-client-experimental 5.108.4 → 6.0.0 Changeset
@tanstack/query-core 5.108.4 → 6.0.0 Changeset
@tanstack/query-devtools 5.108.4 → 6.0.0 Changeset
@tanstack/query-persist-client-core 5.108.4 → 6.0.0 Changeset
@tanstack/react-query 5.108.4 → 6.0.0 Changeset
@tanstack/react-query-devtools 5.108.4 → 6.0.0 Changeset
@tanstack/react-query-next-experimental 5.108.4 → 6.0.0 Changeset
@tanstack/react-query-persist-client 5.108.4 → 6.0.0 Changeset
@tanstack/solid-query 5.108.4 → 6.0.0 Changeset
@tanstack/solid-query-devtools 5.108.4 → 6.0.0 Changeset
@tanstack/solid-query-persist-client 5.108.4 → 6.0.0 Changeset
@tanstack/svelte-query 6.4.7 → 7.0.0 Changeset
@tanstack/svelte-query-devtools 6.4.7 → 7.0.0 Changeset
@tanstack/vue-query 5.108.4 → 6.0.0 Changeset
@tanstack/vue-query-devtools 6.4.7 → 7.0.0 Changeset
@tanstack/angular-query-persist-client 5.108.4 → 6.0.0 Dependent
@tanstack/svelte-query-persist-client 6.4.7 → 7.0.0 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Dec 4, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query

npm i https://pkg.pr.new/@tanstack/angular-query@12748

@tanstack/angular-query-devtools

npm i https://pkg.pr.new/@tanstack/angular-query-devtools@12748

@tanstack/angular-query-persist-client

npm i https://pkg.pr.new/@tanstack/angular-query-persist-client@12748

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@12748

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@12748

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@12748

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@12748

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@12748

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@12748

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@12748

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@12748

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@12748

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@12748

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@12748

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@12748

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@12748

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@12748

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@12748

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@12748

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@12748

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@12748

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@12748

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@12748

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@12748

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@12748

commit: 7e5cd61

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.41 KB (+0.04% 🔺)
react minimal 8.2 KB (+0.05% 🔺)

@TkDodo
TkDodo merged commit 95b6007 into query-v6 Dec 4, 2026
9 checks passed
@TkDodo
TkDodo deleted the schiller-manuel-fix-query-v6-default-scheduler branch December 4, 2026 19:21
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.

2 participants