Monday, 23 August 2021

Firestore suddenly has a huge trigger delay

We are running an application on Firestore and got a simple trigger that when order's details are created or updated some of it's information should be rewritten in the parent order collection.

The function for this got following code

export const updateOrderDetails = functions
  .region(FUNCTION_REGION)
  .firestore.document("orders/{orderId}/details/pickupAndDropoff")
  .onWrite(async (change, context) => {
    return await admin
      .firestore()
      .collection("orders")
      .doc(context.params.orderId)
      .set({ pickupAndDropoff: change.after.data() }, { merge: true });
  });

It was work fine before, but now at random about every third of its executions is delayed. Sometimes by few minutes. In Cloud Function logs we see normal execution times <200ms, so it seems the trigger runs after a huge pause.

What's worse from time to time our change.after.data() is undefined, but we never delete anything - it's just updates and creates.

It was working fine, we did not changed nothing since last week, but now it started to have this unexpected delays. We've also checked the firebase status, but there are no malfunctions in firebase functions service. What can be the cause of this?



from Firestore suddenly has a huge trigger delay

No comments:

Post a Comment