Skip to content

chore: remove duplicate validate calls on same oauth token #11598

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

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Jan 12, 2024

What this does

If we have an invalid token in the db, we should not spam github with the same validate call over and over.

I am not sure how often this was hit in production, since most keys that go invalid expire, which we already check for.

This happens if someone manually revokes a token.

Related to #10853

Thoughts

I think this should really be solved more generally. We should remember when a token is invalid, and not try again. The browser and other things also trigger this call, which we could deduplicate with a cache.

This would save some calls in all cases.

The metrics indicate we are potentially sending more calls from TokenSource thenValidate though.

@Emyrk Emyrk requested a review from johnstcn January 12, 2024 20:07
Comment on lines +214 to +219
if options.NewTicker == nil {
options.NewTicker = func(duration time.Duration) (tick <-chan time.Time, done func()) {
ticker := time.NewTicker(duration)
return ticker.C, ticker.Stop
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK for now but we should probably swap this out for something better later on 🕰️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Some fake clock solution would be ideal, then we can use across all tests more generally.

@Emyrk Emyrk merged commit 03ee639 into main Jan 12, 2024
@Emyrk Emyrk deleted the stevenmasley/validate_debounce branch January 12, 2024 20:27
@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants