Skip to content

⚡️(frontend) optimize document fetch error handling #1089

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

Merged
merged 2 commits into from
Jun 24, 2025

Conversation

AntoLC
Copy link
Collaborator

@AntoLC AntoLC commented Jun 24, 2025

Purpose

Reduce unnecessary fetch requests when retrieving documents with permission or authentication issues. Previous implementation was triggering multiple document requests despite having sufficient error information from initial attempt to determine appropriate user redirection.

Proposal

  • ⚡️(frontend) prevent authentication retry on 401 responses
  • ⚡️(frontend) optimize document fetch error handling

@AntoLC AntoLC added enhancement improve an existing feature frontend labels Jun 24, 2025
@AntoLC AntoLC self-assigned this Jun 24, 2025
@AntoLC AntoLC requested a review from lebaudantoine June 24, 2025 13:30
Copy link
Contributor

@lebaudantoine lebaudantoine left a comment

Choose a reason for hiding this comment

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

LGTM

@AntoLC AntoLC force-pushed the improve/error-retry branch from af52161 to 9be592a Compare June 24, 2025 13:46
Stop retry attempts when receiving 401 Unauthorized from /me endpoint since
this clearly indicates authentication status. The original purpose of the /me
call is simply to determine if user is authenticated, and a 401 provides
sufficient information.

Prevents unnecessary network requests caused by React Query's automatic retry
behavior when re-raising exceptions, which was hiding the 401 status. Improves
performance and reduces server load during authentication failures.
@AntoLC AntoLC force-pushed the improve/error-retry branch from 9be592a to 9269e24 Compare June 24, 2025 13:48
Reduce unnecessary fetch requests when retrieving documents with permission
or authentication issues. Previous implementation was triggering multiple
document requests despite having sufficient error information from initial
attempt to determine appropriate user redirection.

Additionally, fix issue where resetting the auth cache was triggering redundant
authentication verification requests. The responsibility for checking auth
status should belong to the 401 page component on mount, rather than being
triggered by cache resets during error handling.

Known limitations:
- Not waiting for async  function completion makes code harder to
 maintain
- Added loading spinner as temporary solution to prevent UI flicker
- Future improvement should implement consistent error-based redirects rather
 than rendering error messages directly on document page
@AntoLC AntoLC force-pushed the improve/error-retry branch from 9269e24 to 71cd016 Compare June 24, 2025 13:50
@AntoLC AntoLC merged commit 71cd016 into main Jun 24, 2025
20 of 21 checks passed
@AntoLC AntoLC deleted the improve/error-retry branch June 24, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve an existing feature frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants