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

Api retrying #1736

Merged
merged 14 commits into from
Sep 2, 2021
Merged

Api retrying #1736

merged 14 commits into from
Sep 2, 2021

Conversation

yujin-wu
Copy link
Contributor

@yujin-wu yujin-wu commented Aug 31, 2021

This PR makes dash-renderer refresh the Authorization header with a new JWT provided by the request_refresh_jwt hook, upon a server response indicating that the JWT is expired (401 status, and "JWT Expired" in body).

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Add retry with jwt refreshing to apiThunk
    • Add retry with jwt refreshing to callbacks
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md

let newHeaders: Record<string, string> | null = null;
let retry = 0;

while (true) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

while loops always make me uneasy... can this one also be a for like in apiThunk?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✅ Changed to 'for' now. A tad more awkward to get typescript to respect the return type but I agree overall this is better now.

request_pre: null,
request_post: null,
request_refresh_jwt: null,
bear: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

bear is unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was there before I got here ¯_(ツ)_/¯ and yes it is unused

Copy link
Collaborator

Choose a reason for hiding this comment

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

I must be going blind 🙈

@yujin-wu
Copy link
Contributor Author

yujin-wu commented Sep 1, 2021

@alexcjohnson
I have added a simple test.
I have also wrapped the refresh hook in memoize as discussed privately, to prevent effects from race conditions.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃 Beautiful. Lovely test! Will merge once ✅

@alexcjohnson alexcjohnson merged commit 421c3e4 into dev Sep 2, 2021
@alexcjohnson alexcjohnson deleted the api-retrying branch September 2, 2021 18:05
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