Skip to content

call initiate to refetch queries from middleware #4651

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

Merged
merged 2 commits into from
Oct 8, 2024
Merged

Conversation

phryneas
Copy link
Member

@phryneas phryneas commented Oct 6, 2024

This should fix #4650

Previously, middleware-initiated refetches would directly call the thunk, not initiate. While that was probably more performant, that meant that the running thunk would not be tracked in runningQueries, which meant that a subsequent call to initiate could not latch onto the currently-running thunk, and would return the stale value.

It also meant that there were running queries that were not visible to getRunningQueriesThunk/getRunningQueryThunk.

Copy link

codesandbox bot commented Oct 6, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

codesandbox-ci bot commented Oct 6, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4788d51:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

Copy link

netlify bot commented Oct 6, 2024

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 4788d51
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/6704949ed0677b0008448067
😎 Deploy Preview https://deploy-preview-4651--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Oct 6, 2024

size-limit report 📦

Path Size
1. entry point: @reduxjs/toolkit/query/react (modern.mjs) 13.26 KB (+0.01% 🔺)
1. entry point: @reduxjs/toolkit/query (cjs, production.min.cjs) 22.08 KB (-0.1% 🔽)
1. entry point: @reduxjs/toolkit/query/react (cjs, production.min.cjs) 24.1 KB (-0.45% 🔽)
2. entry point: @reduxjs/toolkit/query (without dependencies) (cjs, production.min.cjs) 8.88 KB (-0.15% 🔽)
3. createApi (.modern.mjs) 13.65 KB (-0.06% 🔽)
3. createApi (react) (.modern.mjs) 15.34 KB (+0.01% 🔺)

Copy link
Collaborator

@markerikson markerikson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Would love to see a test cover this.


OKAY FINE I'LL DO IT MYSELF!

@markerikson markerikson merged commit 2885f69 into master Oct 8, 2024
80 checks passed
@markerikson markerikson deleted the pr/fix-4650 branch October 8, 2024 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unwrapping a query when invalidated returns stale data
2 participants