-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat: Pace requests to token server for new auth tokens #83
Conversation
0204158
to
79f7da1
Compare
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.
Took me a second to understand the approach but it looks good! The test is really great and proved the concept to me before I started mentally walking through the branches.
I left a couple of comments but they are purely stylistic, so I'm approving 👍
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.
I think there are potentially ways this might behave unexpectedly in the case where token requests take around 1 minute, but I do think that risk is acceptable given that token requests should not be taking anywhere near that long.
Anyway I'm +1, although it might be worth resetting the requestTime
when the token request completes.
dc71647
to
1f5fa56
Compare
1f5fa56
to
9c0aab8
Compare
# [2.2.0](v2.1.0...v2.2.0) (2020-03-05) ### Features * Pace requests to token server for new auth tokens ([#83](#83)) ([b14dc4e](b14dc4e))
🎉 This PR is included in version 2.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…BM#83) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.9.1 to 4.10.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.10.0/packages/parser) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This PR adds a pacing method to regulate requests to the token service when the current token is invalid (never fetched) or expired. One caller is designated as the "active" request and it issues the request to the token server. Subsequent requests create promises that are added to a list, and the active request resolves (or rejects) these as part of processing the token server response.
Checklist
npm test
passes (tip:npm run lint-fix
can correct most style issues)