linode / linode/manager

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

Open
#10,216 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.