Closed devleejb closed 2 months ago
The changes introduce improved error handling and authorization token management in the application. A retry logic for queries is configured to avoid unnecessary retries on authentication errors, while the authorization token is now set directly within the query function, ensuring the latest token is always used for API requests.
Files | Change Summary |
---|---|
frontend/src/App.tsx |
Added query retry logic to handle Axios errors, specifically avoiding retries on 401 errors. |
frontend/src/hooks/api/user.ts |
Updated the authorization token handling to set the header within the query function for reliability. |
Objective | Addressed | Explanation |
---|---|---|
Intermittent 401 error during login process (Issue #193) | ✅ |
In fields of code, I hop with glee,
New tokens dance, so wild and free.
No more 401s, oh what a treat,
With retries set, our work's complete!
A happy rabbit, I now proclaim,
Error handling's won the game! 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
What this PR does / why we need it:
This PR addresses the intermittent 401 error that occurs during user login. The error was caused by an existing (expired) token being used to fetch user information.
When a token expires, it should be removed quickly to prevent further fetching attempts with the invalid token. The existing retry logic led to unnecessary delays in token deletion, thus prolonging the 401 error response. This update disables the retry mechanism when a 401 error is encountered, allowing for an immediate attempt to log in again with a new, valid token.
Which issue(s) this PR fixes:
Fixes #193
Special notes for your reviewer:
The retry logic was originally implemented to handle network issues; however, when faced with authentication errors like 401, retrying is unnecessary and can lead to a poor user experience. The change ensures that the application responds more efficiently to authentication failures by immediately recognizing the error and moving to the login state.
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes