Firebase Cloud Function Authentication Trigger timing

痞子三分冷 提交于 2020-05-27 07:57:52

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/48292147/firebase-cloud-function-authentication-trigger-timing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!