@linode/api-v4: Race condition for setToken() with multiple token
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 738
- Forks
- 407
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how setToken() updates the shared axios instance used by getKubernetesVersions() in @linode/api-v4. Reproduce concurrent calls with different tokens and determine the supported isolation point. Done means concurrent requests consistently use their intended token, with coverage for the race scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100