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

@linode/api-v4: Race condition for setToken() with multiple token #10216

Open
dwn-phoenixpan opened this issue Feb 21, 2024 · 1 comment
Open

Comments

@dwn-phoenixpan
Copy link

dwn-phoenixpan commented Feb 21, 2024

Hi team,

In general, we call setToken() and then an endpoint, like:

public async getKubeVersions() {
    setToken(linodeToken);
    return await getKubernetesVersions();
  }

The issue is we call the endpoints very often with a lot of different linode tokens. Behind @linode/api-v4 is a single axios instance, we keep chang it's header for different requests using setToken() and this may cause a race condition. For example, if two getKubeVersions() call at the same time, we may have:

setToken(tokenA);
setToken(tokenB);
getKubernetesVersions(); // mean to use tokenA but actually used tokenB
getKubernetesVersions();

Do we have a way to avoid this? For example, to create our own axois instance and call the endpoints from there?

Thanks.

@dwn-phoenixpan
Copy link
Author

I have made a npm patch to the lib so it creates a new axios for each new request...please kindly let me know when we have an update to support multiple linode token concurrently. Thank you.

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