Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Function Authentication Trigger timing

Does anyone knows what the timing of the Firebase Cloud Functions onCreate Authentication Trigger is?

Is it like:
- User registers using SDK
- Firebase creates user in and for Firebase Authentication
- Firebase SDK sends login successful event
- Function onCreate is invoked

or like:
- User registers using SDK
- Firebase creates user in and for Firebase Authentication
- Firebase onCreate is invoked
- Firebase SDK sends login successful event

Or in other words:
Can I be sure that after a successful user registration a Firestore User Document was already created by a short Firebase Cloud Function script?

So can I be sure that when the SDK send the authentication successful callback that the Firestore user document was created?

like image 858
Ichor de Dionysos Avatar asked Oct 28 '22 20:10

Ichor de Dionysos


1 Answers

You are given no guarantees about the timing of the delivery of events to your Cloud Function code. Of course, the system is going to try to deliver as fast as possible. But the fact of the matter is that there can be unpredictable delays at every stage through the processing of that event, so you shouldn't depend on any sort of specific timing. This is especially true when also dealing with other systems that work asynchronously as well, including Firestore (it sounds like you're implying that your function creates a document to read back later in the app).

The good news is that you can listen to the document that you expect to be created for the user, and receive it whenever it's ready.

like image 106
Doug Stevenson Avatar answered Jan 02 '23 20:01

Doug Stevenson