Skip to content

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

Open
ousamabenyounes wants to merge 2 commits intoTanStack:mainfrom
ousamabenyounes:fix/issue-8873
Open

fix(solid-query): skip reconcile when data reference is unchanged#10598
ousamabenyounes wants to merge 2 commits 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
    • Fixed unnecessary callback invocations during query refetches when the data reference remains unchanged, improving performance by preventing redundant operations.

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

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
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

📝 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

Cohort / File(s) Summary
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.
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.

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 specifically describes the main fix: skipping reconcile when data reference is unchanged, which directly addresses the bug fixed in this PR.
Linked Issues check ✅ Passed The PR directly addresses the objective of #8873 by preventing multiple reconcile invocations when data reference is unchanged, verified by the failing test and implementation in useBaseQuery.ts.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objective: a changeset entry, a regression test, and a targeted fix in useBaseQuery.ts to prevent redundant reconcile calls.
Description check ✅ Passed The PR description comprehensively covers the change motivation, implementation approach, test plan with verification steps, and includes a changeset reference.

✏️ 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 06b14a6

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

☁️ Nx Cloud last updated this comment at 2026-04-28 15:52:10 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: 06b14a6

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

2 participants