Realm-js: Have a unique error code for each error message

Created on 6 Oct 2020  路  4Comments  路  Source: realm/realm-js

Goals

Be able to distinguish authentication errors by their code.

Expected Results

Have a unique error code for every error message.

Actual Results

When logging in realm with a JWT token, I can receive the following error codes (among others):

{code:46, message: "user disabled"}
{code:47, message: "(something about authentication failed...) ; token is expired"}
{code:47, message: "failed to lookup key for kid=..."}

The last one occurs when I try to log in my production realm with a staging JWT, for instance.

It doesn't seem logic to me to have the same error code for two different errors, especially since my app should behave differently in case I get a 47 error code:

  • "failed to lookup..." => logout, clear token cache
  • "token expired" => renew token, then retry to log in Realm

Version of Realm and Tooling

  • Realm JS SDK Version: 10.0.0-rc.1
  • Node or React Native: React Native
  • Client OS & Version: macOS 10.15.7
  • Which debugger for React Native: None
O-Community

Most helpful comment

@euZebe The docs team will soon create complete list of error codes with some guidance of error handling.

All 4 comments

@euZebe Realm JS is relaying errors from the server which will make it easier (at least in theory) to correlate the client with the server. I can see that two different errors with the same error code is confusing. In particular since the error codes are not well-documented - either server side or client side.

Let me check with the server team to get better understanding of the error code/categories.

@euZebe The docs team will soon create complete list of error codes with some guidance of error handling.

@kneth, any update on this?

I see the error codes in generic_network_transport, but it would be nice to have documentation like that which exists for the sync errors.

I second the suggestion to have a unique error code per message/issue too. Using 47 for all auth errors requires us to match against a string for error handling, which is much more prone to change.

@caleb-harrelson Unfortunately I haven't any updates to share. But I agree it is something we should get done very soon.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fever324 picture fever324  路  4Comments

bdebout picture bdebout  路  3Comments

ashah888 picture ashah888  路  3Comments

timanglade picture timanglade  路  3Comments

CrystalRanita picture CrystalRanita  路  3Comments