Skip to content

Detect network errors on refresh token #861

Open
@bangerang

Description

@bangerang

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);
  }
}

Metadata

Metadata

Assignees

Labels

enhancementA new featureissue-acceptedThis issue has been confirmed and accepted by the maintainers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions