Open
Description
Hi,
It appears that there's no robust way to check if the refresh request failed due to network errors. This is quite unfortunate, as it means you get logged out if you have no internet, which doesn't provide a great user experience. The only workaround I've found is to explicitly check if the error message contains "Connection error" for iOS and "Network error" for Android, but this feels far from ideal. Perhaps it would be possible to add another error code named "network_error" or something similar? Here's some code for reference:
try {
await refreshToken();
setIsLoggedIn(true);
} catch (error) {
if (message.includes('Connection error') || message.includes('Network error')) {
console.log('Connection error');
} else {
console.log('Refresh token failed, logging out...');
setSessionExpired(true);
setIsLoggedIn(false);
}
}