You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(query-core): use supplied options for optimistic fetches - #12131
Pass the supplied options to Query.fetch from fetchOptimistic. This lets a mounted Suspense query use its local queryFn after broadcast recreates its cache entry without one.
The regression test fails with Missing queryFn before the fix and receives the original 401 Unauthorized error after it. Core tests, core type checks and lint, and the React, Preact, Vue, and Lit test suites pass. The full pnpm run test:pr --base=HEAD~1 check passes (337 tasks).
I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.
🚀 Release Impact
This change affects published code, and I have generated a changeset.
This change is docs/CI/dev-only (no release).
Summary by CodeRabbit
Bug Fixes
Optimistic fetches now use the query options provided for the fetch, including when a query is recreated without a query function. Errors from the supplied query function are correctly propagated.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
QueryObserver.fetchOptimistic now passes its defaulted options to query.fetch. A regression test checks behavior when the observer’s query is recreated without a queryFn.
Changes: Optimistic fetch options
Layer / File(s)
Summary
Pass observer options during optimistic fetch packages/query-core/src/queryObserver.ts, packages/query-core/src/__tests__/queryObserver.test.tsx, .changeset/brown-spoons-occur.md
fetchOptimistic passes defaulted options to query.fetch. The regression test checks that the supplied queryFn runs once and its rejection propagates. A patch changeset records the change.
The fix supports the reported optimistic-fetch scenario, with no identified issue requiring resolution before merge.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly and concisely describes the primary change: passing supplied options to optimistic fetches in query-core.
Description check
The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, test coverage, linked issue, and changeset status. All checklist items are marked app…
Linked Issues check
Issue #12129 requires fetchOptimistic to pass the observer options to Query.fetch when a recreated query has no queryFn. At the reviewed head, packages/query-core/src/queryObserver.ts calls `q…
Out of Scope Changes check
The changes are limited to the required queryObserver.ts fetch call, its regression test, and a patch changeset for @tanstack/query-core. These changes directly support issue #12129. No unrelated …
Docstring Coverage
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Full details: Description check
Explanation
The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, test coverage, linked issue, and changeset status. All checklist items are marked appropriately.
Full details: Linked Issues check
Explanation
Issue #12129 requires fetchOptimistic to pass the observer options to Query.fetch when a recreated query has no queryFn. At the reviewed head, packages/query-core/src/queryObserver.ts calls query.fetch(defaultedOptions). The supplied regression-test summary for packages/query-core/src/__tests__/queryObserver.test.tsx verifies that the supplied queryFn runs once and that its rejection propagates. This implements the required behavior and test coverage.
Full details: Out of Scope Changes check
Explanation
The changes are limited to the required queryObserver.ts fetch call, its regression test, and a patch changeset for @tanstack/query-core. These changes directly support issue #12129. No unrelated change is identified.
Full details: Docstring Coverage
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
Pass the supplied options to
Query.fetchfromfetchOptimistic. This lets a mounted Suspense query use its localqueryFnafter broadcast recreates its cache entry without one.Fixes #12129.
The regression test fails with
Missing queryFnbefore the fix and receives the original401 Unauthorizederror after it. Core tests, core type checks and lint, and the React, Preact, Vue, and Lit test suites pass. The fullpnpm run test:pr --base=HEAD~1check passes (337 tasks).✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit