auth0 / react-native-auth0

React Native toolkit for Auth0 API
https://auth0.com
MIT License
498 stars 210 forks source link

Getting "Network request failed" on iOS app when app is in background #1000

Open Nehal-Zeller opened 2 weeks ago

Nehal-Zeller commented 2 weeks ago

Checklist

Description

I had put the application in background and lets say token also expires at the same time and triggers a refresh call, I get "Network request failed" error in the catch block of auth0.auth.refreshToken but on auth0 dashboard it's logged as successful exchange. When I launch the app again and since app didn't get the new token, it attempts to refresh the token again and this time I get "reuse of token detected" error.

This is difficult to reproduce locally but I was able to get this information from sentry and auth0 dashboard. I've attached the screenshot from sentry and auth0 dashboard, logs can be verified from the same timestamps

Important thing to note here is: this happens only when app is in background. In foreground, everything works as expected.

I would really appreciate some help here.

Screenshot 2024-11-06 at 7 00 23 PM Screenshot 2024-11-06 at 7 02 23 PM

Reproduction

I've no way to reproduce this easily as it happens when app is in background and some background task is triggered when token is already expired.

Issue is faced by number of users but there's no fixed pattern on reproducing it. From the sentry logs, I was able to identify above pattern.

Additional context

No response

react-native-auth0 version

3.2.1

React Native version

0.73.6

Expo version

No response

Platform

iOS

Platform version(s)

on all versions