Skip to content
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

onQueryStarted RTK Query triggers twice #4349

Closed
santirodriguezaffonso opened this issue Apr 15, 2024 · 3 comments
Closed

onQueryStarted RTK Query triggers twice #4349

santirodriguezaffonso opened this issue Apr 15, 2024 · 3 comments

Comments

@santirodriguezaffonso
Copy link

santirodriguezaffonso commented Apr 15, 2024

As the guide mentions, I went first to StackOverflow so for Context and Code go to: https://stackoverflow.com/questions/78329782/onquerystarted-rtk-query-triggers-twice

Well basically as the title mentions. I'm trying to do an optimistic update to a counter but since the onQueryStarted is getting triggered twice I end up with a wrong value.

Alternatively, since I'm in the development stage I've been using the Tags but is not the best performant option for Prod.

Goal

Update the user counting by reducing it by one 'cause I'm removing only one user.

Actual Result

So in the case, I have 10 users result should be 9 but I'm getting 8 as result of onQueryStarted 'cause it's getting called twice

@phryneas
Copy link
Member

Could you please create an isolated reproduction for that? I've never seen this behaviour anywhere and fear we won't be able to reproduce it.

@VladimirPal
Copy link

@santirodriguezaffonso You may duplicate a middleware in your store. It happened with me as well.

@markerikson
Copy link
Collaborator

Closing due to lack of repro.

@markerikson markerikson closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2024
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

No branches or pull requests

4 participants