Repository navigation
fix(toolkit): preserve unsubscribed results during invalidation - #5347
Closed
rajanpanth wants to merge 1 commit into
Closed
rajanpanth wants to merge 1 commit into
rajanpanth wants to merge 1 commit into
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
✅ Deploy Preview for redux-starter-kit-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@reduxjs/rtk-codemods
@rtk-query/codegen-openapi
@rtk-query/graphql-request-base-query
@reduxjs/toolkit
commit: |
Author
|
Friendly follow-up on this PR 👋 When you have a moment, could you please take a look? I’m happy to rebase, update tests, or make any requested changes. Thanks! |
Collaborator
|
Superseded by #5587 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #5346.
Problem
A query initiated with
subscribe: falsecan return an uninitialized result when a mutation triggers delayed invalidation while the query is still running.During the fulfilled dispatch, invalidation sees the cache entry without an active subscription and removes it synchronously.
buildInitiatethen selects the public result after the cache entry has disappeared, so the initiating caller cannot observe the fulfilled data.Root cause
The invalidation middleware removes an unsubscribed query result before the running query promise and initiating result-selection flow have settled.
Change
When the affected cache entry still has a running query, defer cleanup until that query settles.
Before cleanup, recheck:
requestIdAn unchanged unsubscribed entry is removed. A newly subscribed entry is refetched, and a newer request is preserved.
Validation
git show --check— passedThe broad package lint command references an absent
packages/toolkit/examplesdirectory. The optional size-limit command also remains blocked by Windows absolute-path resolution. The changed files pass targeted validation and the production build.Rejected and aborted query results use RTK Query's non-rejecting result promise, so deferred cleanup does not introduce an unhandled rejection. No separate dedicated rejection or abort regression test is included in this change.
Compatibility
No public API, dependency, lockfile, Node support, browser API, or TypeScript declaration change is included.