Cloud / Firebase功能已启动(已触发)但未运行

时间:2020-06-26 11:23:09

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

这是我的测试功能:

export const onTest = functions
  .region('europe-west2')
  .runWith({
    memory: '256MB',
  })
  .firestore.document('pipeline/{docId}').onUpdate( (change, context) => {
    console.log('test');
    return 0;
  });

当我在模拟器中运行它时,我没有问题:我在Firestore模拟器中修改pipeline集合的文档,触发了onTest函数,日志为:

13:13:04 I function[onTest] Beginning execution of "onTest"
13:13:04 I function[onTest] test
13:13:04 I function[onTest] Finished "onTest" in ~1s

但是,如果我部署此功能并在Firestore中修改文档,则这些是我得到的日志:

2020-06-26 12:56:42.990 CEST onTest lsklsthlminq Function execution started
2020-06-26 12:56:42.998 CEST onTest lsklsthlminq Function execution took 8 ms, finished with status: 'ok'

即使该函数被触发,它也似乎未执行。

有任何提示吗?

1 个答案:

答案 0 :(得分:0)

在Cloud Functions中使用Node.js版本10和更高版本时,console.log输出可能不再显示在您正在查看的输出中。

要显示日志,您应该使用:

functions.logger.log("test");

另请参阅firebase-functions 3.7 release notes

相关问题