GeezerVison is showing github.com — fix(query-core): Keep observer notifications stable by scttcper · Pull Request #11234 · TanStack/query
Conversation
scttcper
commented
Aug 20, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
PR #11214 changed observer removal from filter() to splice(). That made removing lots of observers much faster, but it also allowed an observer to change the same array while a query was notifying it. If an observer unsubscribed synchronously, the next observer could be skipped and left with stale data.
This notifies a shallow copy of the observer array. The removal path still uses splice(), so the performance improvement from #11214 stays.
I ran a local Vitest benchmark that calls setQueryData on one query with all observers subscribed:
| Observers |
Before |
After |
| 10 |
0.0027 ms |
0.0027 ms |
| 50 |
0.0096 ms |
0.0101 ms |
| 10,000 |
2.6049 ms |
2.6032 ms |
There isn't a meaningful change in notification time. The key change and unmount paths measured in #11214 are unchanged because this does not change observer removal.
Summary by CodeRabbit
-
Bug Fixes
- Fixed query updates so all remaining observers are notified correctly when another observer unsubscribes during notification.
- Ensured observers receive the latest query data consistently during synchronous updates.
-
Tests
- Added regression coverage for observer notifications during unsubscribe scenarios.
-
Release
- Included in a patch release of
@tanstack/query-core.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Removing an observer in place can shift the active notification loop and skip the next observer. Iterate over a shallow copy so synchronous unsubscriptions keep the old behavior without giving up the faster removal path from TanStack#11214.
Co-Authored-By: Codex <[email protected]>
coderabbitai
Bot
commented
Aug 20, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b133350a-a59a-4e5c-a4be-d39fc870d97e
📥 Commits
Reviewing files that changed from the base of the PR and between 64a8035 and 131504a.
📒 Files selected for processing (3)
.changeset/stable-observers-notify.md
packages/query-core/src/__tests__/query.test.tsx
packages/query-core/src/query.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough
The query dispatch path now snapshots observers before notification. A regression test verifies that remaining observers receive updated data after one observer unsubscribes synchronously. A patch changeset documents the fix.
Changes
Observer notification stability
| Layer / File(s) |
Summary |
Stable dispatch and regression coverage packages/query-core/src/query.ts, packages/query-core/src/__tests__/query.test.tsx, .changeset/stable-observers-notify.md |
Query.#dispatch iterates over a snapshot of observers. The regression test verifies notification of the remaining observer after synchronous unsubscription. The changeset declares a patch release. |
| Estimated code review effort: 2 (Simple) |
~10 minutes |
Merge Risk: ⚪ Minimal · up to 13150
This localized change stabilizes observer notifications while preserving the existing removal performance improvement, and no actionable merge-blocking risk remains after normal checks and review.
Possibly related PRs
Suggested reviewers: tkdodo
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name |
Status |
Explanation |
| Title check |
✅ Passed |
The title clearly describes the main change: stabilizing query observer notifications during synchronous unsubscription. |
| Description check |
✅ Passed |
The description explains the bug, fix, performance impact, and benchmark results, but it omits the template checklist and release-impact headings. |
| 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. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
nx-cloud
Bot
commented
Aug 20, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
View your CI Pipeline Execution ↗ for commit 131504a
| Command |
Status |
Duration |
Result |
nx affected --targets=test:sherif,test:knip,tes... |
✅ Succeeded |
7m 45s |
View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded |
44s |
View ↗ |
☁️ Nx Cloud last updated this comment at 2026-08-20 08:07:42 UTC
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
More templates
@tanstack/angular-query-experimental
npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11234
@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11234
@tanstack/lit-query
npm i https://pkg.pr.new/@tanstack/lit-query@11234
@tanstack/preact-query
npm i https://pkg.pr.new/@tanstack/preact-query@11234
@tanstack/preact-query-devtools
npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11234
@tanstack/preact-query-persist-client
npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11234
@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11234
@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11234
@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@11234
@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@11234
@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11234
@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11234
@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@11234
@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@11234
@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11234
@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11234
@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@11234
@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11234
@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11234
@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@11234
@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11234
@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11234
@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@11234
@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11234
commit: 131504a
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
TkDodo
TkDodo approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|