Skip to content

fix(solid-query): skip reconcile when data reference is unchanged#10598

Open
ousamabenyounes wants to merge 1 commit intoTanStack:mainfrom
ousamabenyounes:fix/issue-8873
Open

fix(solid-query): skip reconcile when data reference is unchanged#10598
ousamabenyounes wants to merge 1 commit intoTanStack:mainfrom
ousamabenyounes:fix/issue-8873

Conversation

@ousamabenyounes
Copy link
Copy Markdown
Contributor

@ousamabenyounes ousamabenyounes commented Apr 26, 2026

Summary

In useBaseQuery, the reconcile path could fire multiple times per logical query update — once for fetching state transitions where result.data was the same reference as the current store data, and again when the actual data resolved. With a user-provided reconcile callback, this surfaced as oldData === newData invocations and 2-4 reconcile calls per request.

This change short-circuits reconcileFn when store.data === result.data. The rest of the result still flows through setState so isFetching / status keep updating reactively.

Closes #8873

Test plan

  • Added failing test that reproduces the bug — useQuery.test.tsx > should not call user-provided reconcile function when result.data reference is unchanged (#8873)
  • Test passes after fix
  • pnpm exec nx run @tanstack/solid-query:test:lib — 310 passed
  • pnpm exec nx run @tanstack/solid-query:test:types — passed
  • pnpm exec nx run @tanstack/solid-query:test:eslint — passed
  • Changeset added

Generated by Ora Studio / Vibe coded by ousamabenyounes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Prevented redundant reconciliation and user-provided callback runs when a query update preserves the same data reference, avoiding unnecessary work and duplicate callbacks.
  • Tests

    • Added a test ensuring reconcile callbacks are invoked only for actual data changes during refetches.
  • Chores

    • Added a release note entry documenting this fix.

Review Change Stack


Generated by Ora Studio (with Claude Code)
Vibe coded by Ben Younes Ousama

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b5000ec3-78e9-4c40-909c-1769fea95bae

📥 Commits

Reviewing files that changed from the base of the PR and between 6d1305d and bc661bc.

📒 Files selected for processing (3)
  • .changeset/solid-query-reconcile-dedup.md
  • packages/solid-query/src/__tests__/useQuery.test.tsx
  • packages/solid-query/src/useBaseQuery.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/solid-query-reconcile-dedup.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/solid-query/src/tests/useQuery.test.tsx
  • packages/solid-query/src/useBaseQuery.ts

📝 Walkthrough

Walkthrough

A patch release for @tanstack/solid-query adds a reference equality check to short-circuit reconciliation when incoming query data is the same reference as the stored data. Includes a regression test and a changeset entry.

Changes

Reconcile deduplication

Layer / File(s) Summary
Core Implementation
packages/solid-query/src/useBaseQuery.ts
Added reference equality check in reconcileFn to short-circuit reconciliation when existing store.data and incoming result.data are the same reference, bypassing user-supplied and fallback reconciliation logic.
Regression Test
packages/solid-query/src/__tests__/useQuery.test.tsx
New test verifying that reconcile callback is not invoked redundantly during refetch operations where the final data reference remains unchanged, asserting rendered values and reconcile call counts and argument identity.
Release Documentation
.changeset/solid-query-reconcile-dedup.md
Changeset entry documenting patch release that prevents repeated reconcile calls when data reference equality is preserved across query updates and references issue #8873.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hop, hop — a tiny dedupe cheer,
When data stays the same, no extra fear.
One reconcile call, tidy and bright,
The store stays calm, the flow just right.
🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: preventing redundant reconcile calls when the data reference is unchanged.
Description check ✅ Passed The description comprehensively covers the issue, solution, test plan, and verification steps with clear section organization.
Linked Issues check ✅ Passed The PR fully addresses issue #8873 by implementing the short-circuit logic to prevent multiple reconcile invocations when data reference is unchanged.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the reconcile callback issue: a test case, implementation fix, and changeset entry.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 26, 2026

View your CI Pipeline Execution ↗ for commit bc661bc

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

☁️ Nx Cloud last updated this comment at 2026-05-09 08:32:45 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 28, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: bc661bc

Previously, the reconcile path in useBaseQuery would invoke the user's
reconcile callback (or the structural reconcile from solid-js/store)
multiple times per logical query update — once for fetching=true
transitions where the data reference had not changed, and again when
the actual data resolved. With user-provided reconcile functions, this
showed up as oldData === newData calls.

Short-circuit reconcileFn when store.data === result.data; the rest of
the result still flows through setState so isFetching/status updates
keep working.

Closes TanStack#8873
Sign up for free to 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.

[Solid-query] reconcile called multiple times on every request

1 participant