Replies: 1 comment
-
you could disable all queries as long as the refresh token is request is running, but I think the axios intercepter might be a better idea. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hej guys, how you deal with refresh token which must go after every request?
Now looks like there is no way to do it properly with bare react-query.
For example, you send refresh request(with cookies credentials) by putting it to queryClient.setDefaultOptions -> mutations -> onSettled, and before start this request wait when useIsFetching returns 0, what's mean there are no other requests and it's safe to request new credentials. But the problem comes when request 1 start -> init refresh token request 2 -> start request 3 -> request 2 success -> request 3 gets invalid credentials error. So 3 was started with old credentials because 2 request the new token and 3 request didn't know about it, and server remove old token before handle request 3.
Possible ways to wrap all useQuery and useMutation with waiting until global refresh token with key 'refresh query' done or solve it with axios request intercepter or just rely on retry after fail(but it provides additional request and doesn't handle case when some useQuery has retry 0), but it looks like a hack.
So I am curios about is there some default feature to set global wait/pause/delay until some query done without manualy adding custom logic to the every useQuery/useMutation in whole project?
Beta Was this translation helpful? Give feedback.
All reactions