Skip to content

Add Retry Mechanism for Token Renewal Failures to Prevent Unnecessary Logout #1062

@bhayart

Description

@bhayart

Currently, when the token renewal process fails in oidc-react, it results in an immediate failure and leads to the user being logged out. This behavior is overly restrictive, especially in cases where the failure is due to transient network issues or temporary server unavailability. This forces users to log back in, which negatively impacts the user experience.

I propose implementing a retry mechanism when the token renewal fails to avoid an immediate logout.
This could include:
Configurable retry logic (e.g., number of retries, delay between retries).
Exponential backoff for retry delays to avoid overwhelming the authentication server.
Option to customize the behavior on failure (e.g., fallbacks or maintaining the session temporarily).
The goal is to prevent unnecessary disconnections and provide a smoother experience when dealing with temporary failures in token renewal.

Use Case:
In environments with network instability or intermittent issues with the identity provider, users can be unexpectedly logged out due to minor, temporary failures in token renewal. Instead of instantly logging the user out, implementing a retry mechanism would allow oidc-react to attempt renewing the token several times before considering the process a true failure, avoiding disruptive logouts.

Proposed Implementation:
Implement a retry mechanism in the UserManager's token renewal process.
Add configuration options to define retry parameters such as maximum retries and backoff strategy.
Log failures and attempts during each retry cycle for debugging and observability purposes.
Ensure the session is preserved during retry attempts, and only logout when retries are exhausted.

Benefits:
Improves user experience by reducing unexpected logouts.
Handles temporary failures more gracefully, especially in unreliable network conditions.
Provides more control over token renewal behavior to developers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions