Skip to content

fix: handle multiple refresh token requests

Navin Karkera requested to merge navin/investigate-tokens into master

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

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.

image

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

  1. Add below part to backend/conf/settings/local.py to expire access_token after 5 seconds.
OAUTH2_PROVIDER = {
    "ACCESS_TOKEN_EXPIRE_SECONDS": 5
}
  1. Start server using make up and frontend using make run.frontend
  2. Login and open devtools network tab.
  3. Click on first item in list after 5 seconds.
  4. Without this commit you should see two requests failing and more two requests for token refreshing.
  5. 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.

Merge request reports