feat: Add automatic retry mechanism for credential retrieval to improve reliability in unstable network conditions #897
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change addresses auth0/react-native-auth0#1374 by improving the reliability of credential retrieval in unstable network conditions.
While this update was initially driven by a request from a React Native SDK consumer, reliable credential retrieval is a critical requirement for mobile scenarios in general. As such, this capability is also applicable to Android SDK consumers and can be leveraged to improve the robustness of credential management.
We should recommend this approach to Android SDK developers who encounter similar issues.
Background / Problem
A scenario highlighted by the community:
getCredentials()and initiates a token refresh.On mobile networks, which are often unreliable, this scenario is realistic. In such cases, even if the user retries later on a stable network, the refresh attempt may fail because the refresh token could already be expired.
Proposed Solution
This PR introduces retry support for transient failures to better leverage Auth0's refresh token rotation overlap period, allowing safe retries when the server-side renewal succeeds but the response never reaches the client.
Outcome
The retry mechanism improves resilience in real-world mobile conditions by safely retrying credential retrieval requests within the refresh token overlap window, reducing unnecessary authentication failures without changing default behavior.
📎 References