I suppose Firestore triggers for cloud functions are using PubSub.
PubSub supports ordering of messages with the same ordering key and in the same region. For Firestore triggers, the ordering key could be the document id.
Ordering would be especially useful for the onUpdate trigger.
CodePudding user response:
Since you're running on an auto-scaling, distributed infrastructure, there are a lot of things that influence the order of execution.
For example if some writes happen in quick succession, one/some of them might require that Cloud Functions spins up a new instance for that write, which then will experience a cold start. Other writes might be handled on existing/warm instances, and there's no way to say which happens first.
Any form of synchronization would require significant effort, which for the vast majority of the cases isn't needed. If you need any synchronization between the invocations, it is up to your Cloud Functions code itself to implement that.
