-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix(query-persist-client-core): allow restoring null values #9747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: c9443b3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughIntroduces a changeset for a patch release and modifies createPersister restoration logic to treat undefined distinctly from null. Restoration now occurs when data is not undefined, allowing null to be a valid restored value rather than triggering a refetch. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App
participant Persister as createPersister
participant Storage
App->>Persister: restore()
Persister->>Storage: read()
Storage-->>Persister: restoredData
alt restoredData !== undefined
note right of Persister: New behavior: null is valid
Persister-->>App: return restoredData (may be null)
else restoredData is undefined
Persister->>Storage: fetch and persist fallback
Persister-->>App: return fetched data
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
View your CI Pipeline Execution ↗ for commit c9443b3
☁️ Nx Cloud last updated this comment at |
Sizes for commit c9443b3:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/query-persist-client-core/src/createPersister.ts (1)
224-226
: Excellent fix for null value restoration.The change from loose (
!=
) to strict (!==
) equality correctly distinguishes betweenundefined
(no persisted data found, should fetch) andnull
(explicitly persisted null value, should restore). This semantic distinction aligns with JavaScript conventions.Consider adding a brief inline comment to clarify the distinction:
+ // Restore if we found persisted data (including explicit null values) + // undefined means no data was found, so we should fetch instead if (restoredData !== undefined) { return Promise.resolve(restoredData as T) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.changeset/tender-cameras-brush.md
(1 hunks)packages/query-persist-client-core/src/createPersister.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (2)
.changeset/tender-cameras-brush.md (1)
1-5
: LGTM!The changeset is properly formatted and clearly describes the change. The patch version bump is appropriate for this behavioral fix in an experimental feature.
packages/query-persist-client-core/src/createPersister.ts (1)
224-226
: Verify downstream handling of null query data. Persistednull
is now returned (not treated as missing) and won’t trigger refetches—ensure all consuming hooks/components handlenull
values correctly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9747 +/- ##
===========================================
+ Coverage 45.53% 80.88% +35.34%
===========================================
Files 196 36 -160
Lines 8327 659 -7668
Branches 1894 186 -1708
===========================================
- Hits 3792 533 -3259
+ Misses 4093 109 -3984
+ Partials 442 17 -425
🚀 New features to boost your workflow:
|
🎯 Changes
experimental persister now allows to restore
null
valuesFixes: #9658
✅ Checklist
pnpm test:pr
.🚀 Release Impact
Summary by CodeRabbit