Skip to content

Multiple Axios Instances Triggering Duplicate refreshAuthLogic Calls #286

@vijay-talviya

Description

@vijay-talviya

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions