@linode/api-v4: Race condition for setToken() with multiple token
dwn-phoenixpan opened this issue · comments
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.
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.