fix: handle multiple refresh token requests
Currently, when access_token expires axios intercepts failed requests and use refresh_token to get new access_token. It then resends the failed request. In case of multiple requests with expired access_tokens we were creating multiple requests to refresh token causing random behaviour. This commit creates a single request for refreshing token and makes other requests wait for it before continuing.
Supporting information
-
Private ref
Jira ticket: BB-6679 - GitLab issue: #53 (closed)
Visual changes
- To indicate that the label or some parts of the list row is clickable,
role="button"
is added. This updates the pointer shape properly.
Testing instructions
I could not reproduce the exact behavior described in #53 (closed), but found this issue with multiple token requests which can be tested.
Step by step produce
- Add below part to
backend/conf/settings/local.py
to expire access_token after 5 seconds.
OAUTH2_PROVIDER = {
"ACCESS_TOKEN_EXPIRE_SECONDS": 5
}
- Start server using
make up
and frontend usingmake run.frontend
- Login and open devtools network tab.
- Click on first item in list after 5 seconds.
- Without this commit you should see two requests failing and more two requests for token refreshing.
- With this commit, only one request should be sent for refreshing the token and then the other requests should be successful.
Author notes and concerns
As mentioned in testing section. I could not reproduce the behavior described in the issue using Firefox.