Skip to content

fix(core): make sure that calling setOptions will always notifyListeners - #8771

Merged
TkDodo merged 5 commits into
mainfrom
feature/missing-fetchStatus-updates
Mar 28, 2025
Merged

fix(core): make sure that calling setOptions will always notifyListeners#8771
TkDodo merged 5 commits into
mainfrom
feature/missing-fetchStatus-updates

Conversation

@TkDodo

Copy link
Copy Markdown
Collaborator

we have an optimized shouldNotifyListeners logic internally in the QueryObserver that will make sure we only notify listeners that are interested in a change because they are using a specific key (tracked query properties)

the optimization to force a skip of the notification when updating options because the optimistic result should already contain all the necessary output falls apart in the situation described in the test and in the linked issue #8741.

while the issue itself is a niche edge-case, the fix is to actually remove a bunch of code, so I'm all for it

fixes#8741

we have an optimized `shouldNotifyListeners` logic internally in the QueryObserver that will make sure we only notify listeners that are interested in a change because they are using a specific key (tracked query properties)
the optimization to force a skip of the notification when updating options because the optimistic result should already contain all the necessary output falls apart in the situation described in the test and in the linked issue #8741.
while the issue itself is a niche edge-case, the fix is to actually remove a bunch of code, so I'm all for it
@nx-cloud

nx-cloudBot commented Mar 8, 2025

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit ab0ff6c.

CommandStatusDurationResult
nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded3m 13sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded2mView ↗

☁️ Nx Cloud last updated this comment at 2025-03-27 20:01:41 UTC

@pkg-pr-new

pkg-pr-newBot commented Mar 8, 2025

Copy link
Copy Markdown

Open in Stackblitz

More templates

@tanstack/angular-query-devtools-experimental

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

@tanstack/angular-query-experimental

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

@tanstack/query-async-storage-persister

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

@tanstack/eslint-plugin-query

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@8771

@tanstack/react-query

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-devtools

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: ab0ff6c

@github-actions

github-actionsBot commented Mar 8, 2025

Copy link
Copy Markdown
Contributor

Sizes for commit ab0ff6c:

BranchBundle Size
Main
This PR

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lachlancollins for the svelte-query persist plugin, there seems to now be one additional render / update. Interestingly, this doesn’t happen for the react adapter. we have the same tests and had the same assertions until now.

@codecov

codecovBot commented Mar 8, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.39%. Comparing base (b23bb39) to head (ab0ff6c).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@ Coverage Diff @@## main #8771 +/- ##
===========================================
+ Coverage 46.60% 63.39% +16.78% 
===========================================
Files 200 136 -64 Lines 7576 4860 -2716 Branches 1744 1371 -373 ===========================================
- Hits 3531 3081 -450 + Misses 3669 1538 -2131 + Partials 376 241 -135 
ComponentsCoverage Δ
@tanstack/angular-query-devtools-experimental∅ <ø> (∅)
@tanstack/angular-query-experimental88.08% <100.00%> (ø)
@tanstack/eslint-plugin-query∅ <ø> (∅)
@tanstack/query-async-storage-persister43.85% <ø> (ø)
@tanstack/query-broadcast-client-experimental∅ <ø> (∅)
@tanstack/query-codemods∅ <ø> (∅)
@tanstack/query-core94.82% <100.00%> (-0.01%)⬇️
@tanstack/query-devtools4.78% <ø> (ø)
@tanstack/query-persist-client-core57.73% <ø> (ø)
@tanstack/query-sync-storage-persister84.61% <ø> (ø)
@tanstack/react-query95.42% <100.00%> (ø)
@tanstack/react-query-devtools10.00% <ø> (ø)
@tanstack/react-query-next-experimental∅ <ø> (∅)
@tanstack/react-query-persist-client100.00% <ø> (ø)
@tanstack/solid-query78.20% <ø> (ø)
@tanstack/solid-query-devtools∅ <ø> (∅)
@tanstack/solid-query-persist-client100.00% <ø> (ø)
@tanstack/svelte-query87.33% <100.00%> (ø)
@tanstack/svelte-query-devtools∅ <ø> (∅)
@tanstack/svelte-query-persist-client100.00% <ø> (ø)
@tanstack/vue-query71.01% <ø> (ø)
@tanstack/vue-query-devtools∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React Query - Missing fetchStatus changes for disabled queries with dynamic keys

1 participant

@TkDodo