Skip to content

Race condition when reusing OauthClient across goroutines #4

@francescobianco

Description

@francescobianco

Description
Using a shared OauthClient in concurrent workers causes inconsistent token responses.

Code snippet

oauthClient := client.NewOauthClient(user, apiKey, true)

wg := sync.WaitGroup{}
for i := 0; i < 10; i++ {
    wg.Add(1)
    go func() {
        defer wg.Done()
        _, _ = oauthClient.CreateToken(context.Background(), scopes, 3600)
    }()
}
wg.Wait()

Observed behavior
Occasional malformed responses or errors.

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