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 query update yields the same data reference, reducing unnecessary work.
  • Tests

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

    • Added a release note entry documenting the fix.

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

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 435f4546-bf70-4c77-acaa-796b96812e33

📥 Commits

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

📒 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/useBaseQuery.ts
  • packages/solid-query/src/tests/useQuery.test.tsx

📝 Walkthrough

Walkthrough

A patch release for @tanstack/solid-query adds a reference equality check to prevent redundant reconcile invocations when query data reference remains unchanged. Includes a regression test and changeset documentation.

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 value and incoming result value share 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 data reference remains unchanged, with assertions validating correct oldData/newData comparison pairs.
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.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hop hop, a fix for the reconcile,
No more duplicates, single and beguile,
When data stays the same, we skip the call,
One sweet reconcile, that's all, that's all! 🥕

🚥 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 clearly and concisely summarizes the main fix: skipping reconcile calls when the data reference remains unchanged, which directly addresses the primary issue.
Description check ✅ Passed The description covers the problem statement, solution approach, test verification, and includes a changeset. It follows the template with the 🎯 Changes section and checklist items marked, though explicitly filling in template sections could be clearer.
Linked Issues check ✅ Passed The PR successfully addresses issue #8873 by preventing redundant reconcile callback invocations when data references are unchanged, matching the expected behavior and implementation requirements described in the issue.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the issue: a changeset entry, a test case reproducing the bug, and the fix in useBaseQuery.ts. No unrelated modifications are present.

✏️ 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 6d1305d

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

☁️ Nx Cloud last updated this comment at 2026-05-07 09:24:06 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/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: 6d1305d

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