Firebase后台功能触发晚

时间:2019-03-11 00:41:02

标签: firebase google-cloud-firestore google-cloud-functions

在更新了实际的Firestore文档后几分钟,似乎已触发了某些Firestore后台功能:

functions.firestore.document('users/{userId}/followings/{followingUserId}')
      .onCreate((snap, context) => {
        const now = moment();
        if(moment.duration(now.diff(moment(context.timestamp))).as("seconds") >= 150) {
          console.info("now: ", JSON.stringify(now));
          console.info("context.timestamp: ", 
           JSON.stringify(context.timestamp));
          ...
        }
        ...

这是日志中的内容:

 <function_name> 428884432521740 context.timestamp:  "2019-03-10T23:28:52.458755Z" I  <function_name> 428884432521740
 <function_name> 428884432521740 now:  "2019-03-10T23:33:25.297Z" I  <function_name> 428884432521740

Firestore的official documentation状态:

It may take up to 10 seconds for a function to be triggered after a change to Cloud Firestore data

为什么触发背景功能要花比预期更长的时间?

0 个答案:

没有答案