-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Initiate returns undefined when unwrapping after resetApiState #4833
Comments
@Cambrionix-Matt : what is the code sequence and timing of |
I think resetApIState was triggered around the same time the initiate was fulfilled. I won't be able to repo properly until next week but the general structure was API 1 has an endpoint getData1 API 2 has an endpoint getData2 which calls api1.getData.initiate(). unwrap () inside the base query 2 There is a listener middleware which listens for Api1.getData1.matchFufilled and dispatched api2.resetAPIState (ie around the same time api2.getData2 is unwrapped) |
If |
Yeah I'm not too surprised it went wrong - and the fix our end was just to not reset the API state as it was definitely not the right thing to be doing! I still think this is a bug if the types suggested it should never return undefined |
I'd disagree on that. The types are accurate for intended usage. adding |
I think the ideal fix is to reject all initiate which are pending before the cache is removed. In the intended scenario for resetAPIState would you be able to guarantee that it wouldn't have any queries which happen to be resolved at the same time as calling reset, and what would happen if the initiate has not yet resolved? |
I have places in my application where i call
but when I call api.util.resetApiState() these return undefined, despite the type suggesting otherwise.
Either the initiate should reject, return the old response before the api is reset, or the types should be updated to match the behavior.
The text was updated successfully, but these errors were encountered: