Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix concurrency issues #267

Merged
merged 1 commit into from
Aug 29, 2024
Merged

Fix concurrency issues #267

merged 1 commit into from
Aug 29, 2024

Conversation

pierluc-codes
Copy link
Contributor

@pierluc-codes pierluc-codes commented Aug 28, 2024

🛠️ Description

Fixes parallelism problem where multiple token exchange happen if the code is invoked by multiple go routine. The lock also act as a protector for the cached file on the filesystem.

The crash can be reproduced by simulating a slower than expected response from the oauth webserver with the the following patch

diff --git a/auth/browser.go b/auth/browser.go
index fc10933..8559cfe 100644
--- a/auth/browser.go
+++ b/auth/browser.go
@@ -87,6 +87,7 @@ func (b *oauthBrowser) GetTokenFromBrowser(ctx context.Context, conf *oauth2.Con
 			return nil, err
 		}
 
+		time.Sleep(time.Second * 4)
 		err = callbackEndpoint.server.Shutdown(context.Background())
 		if err != nil {
 			return nil, fmt.Errorf("failed to shutdown callback server: %w", err)

🔗 External Links

👍 Definition of Done

  • SDK added
  • SDK updated
  • Tests added?
  • Docs updated?

@pierluc-codes pierluc-codes force-pushed the pierluc-codes/fix-concurrency branch 3 times, most recently from 4e79deb to 9d41927 Compare August 28, 2024 19:39
@pierluc-codes pierluc-codes marked this pull request as ready for review August 28, 2024 19:40
@pierluc-codes pierluc-codes merged commit f361dae into main Aug 29, 2024
3 checks passed
@pierluc-codes pierluc-codes deleted the pierluc-codes/fix-concurrency branch August 29, 2024 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants