Repository navigation
fix(query-persist-client-core): use setTimeout instead of notifyManager.schedule - #12749
Conversation
…er.schedule Backport the createPersister.ts change from TanStack Query #12662 (v6) to v5. experimental_createQueryPersister needs a macrotask after queryFn resolves so query.setData applies before persisting state or running afterRestoreMacroTask, even when consumers configure a microtask scheduler via notifyManager.setScheduler. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 0220819 The changes in this PR will be included in the next version bump. This PR includes changesets to release 26 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 |
|
View your CI Pipeline Execution ↗ for commit 0220819
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview3 package(s) bumped directly, 23 bumped as dependents. 🟩 Patch bumps
|
size-limit report 📦
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…er tests Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🎯 Changes
Backports the
packages/query-persist-client-core/src/createPersister.tschange from #12662 (v6) to v5.experimental_createQueryPersisterneeds a macrotask afterqueryFnresolves soquery.setDataapplies before persisting state or runningafterRestoreMacroTask. Previously both callbacks were scheduled vianotifyManager.schedule, so configuring a microtask scheduler vianotifyManager.setSchedulercaused them to run beforequery.setData, overwriting restoreddataUpdatedAt, skipping stale refetches whilefetchStatuswas still'fetching', and persisting pending state withdata: undefinedanddataUpdatedAt: 0.Replacing both calls with direct
setTimeout(..., 0)ensures query state settles first regardless of the configurednotifyManagerscheduler.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit