Skip to content

Conversation

@chlowell
Copy link
Member

@chlowell chlowell commented Mar 8, 2023

Sharing a credential instance among goroutines can produce redundant token requests because goroutines may race to populate the credential's cache. This PR refactors GetToken() into two callbacks, one for silent auth (checking the cache) and one for requesting a new token, and adds a new syncer type to synchronize them. (Credentials that don't distinguish checking the cache from requesting a token use the same method for both callbacks.) Credentials will allow only one goroutine to authenticate at a time, and waiting goroutines will check the cache again when they wake up. Closes #20044

@chlowell chlowell merged commit 1e6d6d9 into release/azidentity-1.3.0-beta Mar 8, 2023
@chlowell chlowell deleted the chlowell/excess-requests branch March 8, 2023 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants