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

Multiple Axios Instances Triggering Duplicate refreshAuthLogic Calls #286

Open
vijay-talviya opened this issue Jun 14, 2024 · 0 comments
Open

Comments

@vijay-talviya
Copy link

I've configured two instances of Axios, each config with its createAuthRefreshInterceptor to manage token refresh. these Axios instances interact with distinct servers, yet both servers employ the same authentication mechanism. However, I've encountered a scenario where both Axios instances are invoked simultaneously within a single useEffect hook. This results in concurrent token refresh requests using the same refresh token. While the first API call successfully refreshes the token, the second one fails and else logic executed

createAuthRefreshInterceptor(axios1, refreshTokenWrapper)
createAuthRefreshInterceptor(axios2, refreshTokenWrapper)

I want the token refresh process to be initiated only once in response to a 401 error across multiple instance APIs. Subsequent failed API calls should wait for the token refresh to complete before retrying, instead of triggering additional refresh requests

is there any way to achieve this?

@vijay-talviya vijay-talviya changed the title Multiple Time refreshAuthLogic is running when multiple axios instance Multiple Axios Instances Triggering Duplicate refreshAuthLogic Calls Jun 14, 2024
@vijay-talviya vijay-talviya reopened this Jun 14, 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

1 participant