You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working to integrate Firebase auth into an application. If Firebase issues an error, I'm having trouble catching it if using the Redwood auth interface. The exceptions all go unhandled. Catching exceptions from async functions can be tricky and there seems to be something special about how Firebase is returning promises that seem to require a promise .catch block. A try { await} catch {} arrangement does not appear to work with Firebase's promises.
Currently, the only solution I've found (with the existing RedwoodJS codebase) is to go directly to the firebase API to catch the error.
For context, I'm getting the client and signup functions from the useAuth() hook: const { client, signUp } = useAuth()
and neither does a try { await } catch arrangement.
I played with the firebase.ts code in the Auth package and could get it to work if I get rid of the async function and wrapped it in a new promise. The code I got working is:
I'm working to integrate Firebase auth into an application. If Firebase issues an error, I'm having trouble catching it if using the Redwood auth interface. The exceptions all go unhandled. Catching exceptions from async functions can be tricky and there seems to be something special about how Firebase is returning promises that seem to require a promise .catch block. A try { await} catch {} arrangement does not appear to work with Firebase's promises.
Currently, the only solution I've found (with the existing RedwoodJS codebase) is to go directly to the firebase API to catch the error.
For context, I'm getting the client and signup functions from the
useAuth()
hook:const { client, signUp } = useAuth()
This works to catch an error:
This doesn't work to catch an error:
And for the RedoodJS part, this doesn't work to catch an error:
and neither does a try { await } catch arrangement.
I played with the firebase.ts code in the Auth package and could get it to work if I get rid of the async function and wrapped it in a new promise. The code I got working is:
Thanks!
The text was updated successfully, but these errors were encountered: