dbAuth: Catch fetch failure in getToken #9119
Merged
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.
We have this comment in
useToken()
redwood/packages/auth/src/AuthProvider/useToken.ts
Lines 7 to 14 in 4b734d3
And for example our Netlify auth implementation does this:
redwood/packages/auth-providers/netlify/web/src/netlify.ts
Lines 68 to 78 in 4b734d3
But dbAuth let the exception slip through to
useToken
.This PR adds a
catch
to the promise and returnsnull
, just like Netlify (and others)Before merging this though, I need to make sure I'm not undoing the fix @standup75 did in #8284
(@standup75 can you say off the top of your head if my code will work or not?)