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

Mutation get stuck in pending state #4447

Open
LucasHimelfarb opened this issue Jun 6, 2024 · 18 comments
Open

Mutation get stuck in pending state #4447

LucasHimelfarb opened this issue Jun 6, 2024 · 18 comments

Comments

@LucasHimelfarb
Copy link

In my React Native application, I implement React Navigation and have two stack navigators... After replacing one with the other, a screen is rendered that will make two requests using RTK Query. The first is a simple query to obtain some authorization tokens, which resolves without any issues. The second is a mutation that implements a queryFn...

Screenshot 2024-06-06 at 2 17 26 PM

and those queries called in my screen:

Screenshot 2024-06-06 at 2 19 10 PM

But the getCredits mutation never resolve with success even if the requests defined in queryFn was resolved, the data value is unfilled in the screen side and the flag isLoading is always true.

All works fine when the replace of stack navigators never happens

@phryneas
Copy link
Member

phryneas commented Jun 6, 2024

I fear this is way too specific for any of us to reproduce and look at - if you can build some more generic reproduction that we can actually run, we could take a look, but like this I'm not sure we can help you, sorry :/

@LucasHimelfarb
Copy link
Author

@phryneas It s a company project so is hard to share a reproducible case for u. But I swear my implementation is so simple like that. May be is useful look my root navigator:

Screenshot 2024-06-06 at 5 34 21 PM

@LucasHimelfarb
Copy link
Author

@phryneas and funny fact: if I remove all code lines on queryFn and just return an empty array the problem persist

@aryaemami59
Copy link
Contributor

Can you tell us what version of Redux-toolkit, React-Redux, React-Native and React you're running? Maybe that'll give some sort of clue as to where the issue is coming from.

@LucasHimelfarb
Copy link
Author

@aryaemami59 of course...

"@reduxjs/toolkit": "2.2.5"
"react-redux": "9.1.0",
"react-native": "0.73.5",
"react": "18.2.0",

@LucasHimelfarb
Copy link
Author

after many hours trying different approaches I can't get it... I think it is a bug related between RTKQuery and react-navigation/native

@aryaemami59
Copy link
Contributor

@LucasHimelfarb Can you add this to your package.json's dependencies and try again?

"@reduxjs/toolkit": "https://pkg.csb.dev/reduxjs/redux-toolkit/commit/d86ec94b/@reduxjs/toolkit",

@LucasHimelfarb
Copy link
Author

Thanks for u suggest @aryaemami59

Getting the same behavior :/

@aryaemami59
Copy link
Contributor

@LucasHimelfarb this is a longshot, but can you also try with the most recent React-Redux version?

@LucasHimelfarb
Copy link
Author

@aryaemami59 I tried it together with the last thing you shared with me and with the latest version of react-redux (9.1.2) and I get the same behavior

@aryaemami59
Copy link
Contributor

@LucasHimelfarb Then in that case, I think our best bet is if you put together a small repro, I understand it's probably time consuming, but it's very difficult to tell what's going on without having a sample of the problem to look at.

@Almada2021
Copy link

Almada2021 commented Jun 10, 2024

Hello when a navigator stack is replaced, is it possible that the mutation state is lost or reset ?

@LucasHimelfarb
Copy link
Author

@aryaemami59 In this week I can't build a repo to reproduce the error because my job... but I'll try to do it on the weekend....
@Almada2021 I think no, I don't see any repeat log or actions dispatched twice

@aryaemami59
Copy link
Contributor

@LucasHimelfarb Awesome. Let me know when you do so I can take a look.

@teaglebuilt
Copy link

teaglebuilt commented Jun 22, 2024

I am facing this same issue. I will also note that uninitialized is true. @LucasHimelfarb if you console.log isUninitialized, is it true? You can export if from your mutation dict along with isLoading, isError, etc...

@david10sing
Copy link

david10sing commented Jun 27, 2024

Might this be related? I would try rolling back to v2.2.3 to confirm that v2.2.4 changes is the cause if the issue here.

#4449

@LucasHimelfarb
Copy link
Author

@aryaemami59 new update: this happened only with queryFn thats not return a string as a data

@aryaemami59
Copy link
Contributor

@LucasHimelfarb sorry you said this only happens if queryFn returns something other than a string? Do you have a small example or maybe even a code snippet? I can take a closer look, I just need to know what to look for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants