fix: return a rejected promise when inner token is null or undefined #83
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.
Related to decaporg/decap-cms#941, specifically decaporg/decap-cms#941 (comment)
When a call to
_refreshToken
inside thejwt
methods fails, the inner token property is set to null here:gotrue-js/src/user.js
Line 95 in 7f85187
That can happen when the refresh token is no longer valid as specified here netlify/netlify-identity-widget#142 (comment)
Subsequence calls to
jwt
will fail when trying to access a null token, but won't return a rejected promise thus breakingcatch
clauses like these ones:gotrue-js/src/user.js
Line 72 in 7f85187
https://github.com/netlify/netlify-identity-widget/blob/c104dd18bb3b87d2a66936e15f064d5659259686/src/state/store.js#L146
since
jwt
is called on each_request
that makes error handling very problematic once a refresh operation fails.The fix is to return a rejected promise if the token is
null
orundefined