-
Notifications
You must be signed in to change notification settings - Fork 407
Cache token scope check failures #1871
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1871 +/- ##
==========================================
+ Coverage 91.14% 91.21% +0.06%
==========================================
Files 196 196
Lines 10745 10745
Branches 1575 1574 -1
==========================================
+ Hits 9794 9801 +7
+ Misses 951 944 -7
Continue to review full report at Codecov.
|
|
From manual testing - here's the call log from master: And here's the call log from this branch: We still have two duplicated HEAD requests; that's because we have two calls to |
vanessayuenn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@annthurium and I discussed to implement a mentionable user fallback for an insufficient token scope by loading the authors from last n commits instead of just showing nothing. But I would be happy to address this in another PR so we don't hold up release.
I left a question, but this otherwise LGTM 👍 .
Yeah, this is kind of what I was thinking 😄 I'll file another issue for that so we don't lose track of it. |
|
Filed as #1872. ✨ |
Cache token scope check failures


Please be sure to read the contributor's guide to the GitHub package before submitting any pull requests.
Requirements
Description of the Change
I've changed
GithubLoginModelto cache not just the set of successfully authenticated tokens, but also tokens that have resulted in authentication failures or those that don't have sufficient OAuth scopes to be used.I did not cache tokens that fail the scope-check because the
fetchcall raised an error, to prevent us from remembering the failure from a transient network error (or a GitHub outage).Alternate Designs
We may also be able to address this with careful handling of how
GithubLoginModel::getToken()is called, ensuring that it's only ever retried when the token has actually changed. Fixing it withingetToken()feels more robust.Benefits
We will no longer lock users out with rate-limit errors when the token stored in your OS keychain is revoked or older than the last time that we've changed the required OAuth scopes.
Possible Drawbacks
The Map of checked tokens could, theoretically, grow without bound. For it to be an issue you'd need to revoke and regenerate tokens millions of times. I'm guessing that the GitHub API would become unhappy with you long before your RAM started to noticeably bloat.
Applicable Issues
Fixes #1868.
Metrics
N/A
Tests
I've added unit tests to
GithubLoginModelto test the caching of various kinds of failures.To test it manually, I'll:
console.logto trace each time we're doing the scope check.Documentation
N/A
Release Notes
User Experience Research (Optional)
N/A