Skip to content

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

@dwn-phoenixpan

Description

@dwn-phoenixpan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions