Skip to content

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

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

fix(solid-query): skip reconcile when data reference is unchanged#10598
ousamabenyounes wants to merge 1 commit into
TanStack: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

    • Avoid redundant reconciliation and skip user-provided reconcile callbacks when an update preserves the same data reference, reducing unnecessary work and duplicate callbacks.
  • Tests

    • Added a test ensuring reconcile callbacks run only when the data reference actually changes during refetches.
  • Chores

    • Added a release note entry documenting this behavior.

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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3290ad17-1409-4705-872a-064ee30ae338

📥 Commits

Reviewing files that changed from the base of the PR and between 6f43e91 and 3cab82c.

📒 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.

Sequence Diagram(s)

sequenceDiagram
  participant Store
  participant ReconcileFn
  participant Result
  Store->>ReconcileFn: provide store.data
  Result->>ReconcileFn: provide result.data
  ReconcileFn->>ReconcileFn: compare store.data === result.data
  alt equal
    ReconcileFn-->>Store: return result (short-circuit)
  else not equal
    ReconcileFn->>Reconcile: call user reconcile / structural reconcile
    Reconcile-->>Store: updated store.data
  end
Loading

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 | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Description check ❓ Inconclusive The PR description includes a summary of changes, test plan with verification steps, and mentions the changeset. However, the author-provided description does not follow the repository template structure with the '🎯 Changes', '✅ Checklist', and '🚀 Release Impact' sections as specified in the template. Consider using the repository's PR template with the required sections for consistency, though the information provided is substantive.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(solid-query): skip reconcile when data reference is unchanged' is clear, specific, and accurately describes the main change in this PR.
Linked Issues check ✅ Passed The PR successfully addresses issue #8873 by preventing redundant reconcile executions when data reference is unchanged, adding a test that reproduces and validates the fix, and all tests pass.
Out of Scope Changes check ✅ Passed All changes are directly related to the issue objectives: a changeset entry, a test for the specific bug, and a fix to short-circuit reconcileFn when data references are identical.

✏️ 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 3cab82c

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

☁️ Nx Cloud last updated this comment at 2026-05-11 08:41:37 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: 3cab82c

@ousamabenyounes ousamabenyounes force-pushed the fix/issue-8873 branch 3 times, most recently from bc661bc to 6f43e91 Compare May 10, 2026 08:30
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