Skip to content

How to handle network errors in the middle of createUser flow? #503

Open
@compojoom

Description

@compojoom

I was greeted today by a bug report. The report was saying - user can't create anything.
I looked into the authentication page on firebase and grabbed the user's id. Then I went in firestore and tried to look his profile in the database - it was missing... That's impossible I thought - when we create a user, we have a profileFactory and it is responsible for writing to firestore. We save the email, uid, name etc in firestore.

Then I looked at our code and in the code of redux-firebase and realized that the only way this to happen is for the internet connection to be interrupted in the exact moment after logging in the user.
I tried to reproduce this and it turned out that I was correct.
here are the actions
grafik
I managed to cut out the internet connection right after firebase/LOGIN, then SET_PROFILE fails with unauthorized_error. The actual error code there is firestore/unavailable.

Any ideas how to recover from this (other than to have a stable internet connection :))?

is there an easy way around this problem? Right now what I am thinking about is giving up using createUser and writing a cloud function that receives all the data needed to register the user. Once the user is registered on the server, I can copy his data to the users collection & then I'll return a success to the app and the app could try to login with the email and password the user provided.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions