Skip to content

Conversation

markerikson
Copy link
Collaborator

This PR:

  • Adds a new dev mode check to configureStore that throws an error if duplicate middleware references are found
  • Adds a new duplicateMiddlewareCheck option to configureStore to control that behavior

Per issues like #4349 , apparently some folks have managed to accidentally add the same middleware to the store twice (and specifically, the same RTKQ middleware, like gDM().concat(baseApi.middleware, injectedApi.middleware)... which is wrong because those are the exact same object and middleware references).

Adding a trivial Set + reference checks seems to catch that.

I don't think this is common enough to be a major problem, but it was easy enough to throw this check in and add tests + docs, so why not.

Copy link

codesandbox bot commented Apr 7, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

codesandbox-ci bot commented Apr 7, 2025

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 bc46637:

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

Copy link

github-actions bot commented Apr 7, 2025

size-limit report 📦

Path Size
1. entry point: @reduxjs/toolkit/react (cjs, production.min.cjs) 14.38 KB (+0.04% 🔺)
1. entry point: @reduxjs/toolkit/query (cjs, production.min.cjs) 23.96 KB (+0.13% 🔺)
1. entry point: @reduxjs/toolkit/query/react (cjs, production.min.cjs) 26.32 KB (+0.09% 🔺)
2. entry point: @reduxjs/toolkit (without dependencies) (cjs, production.min.cjs) 7.59 KB (+0.11% 🔺)
3. configureStore (.modern.mjs) 1.77 KB (+0.78% 🔺)

Copy link

netlify bot commented Apr 7, 2025

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

Name Link
🔨 Latest commit bc46637
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/67f32e8d7ae557000902766b
😎 Deploy Preview https://deploy-preview-4927--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.

@markerikson markerikson merged commit e730507 into master Apr 7, 2025
116 checks passed
@aryaemami59 aryaemami59 deleted the feature/dupe-middleware-check branch April 7, 2025 10:36
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.

1 participant