【发布时间】:2019-02-13 20:32:45
【问题描述】:
我觉得我至少应该看到一个错误,或者..如果一反常态地幸运,成功。我在/sampleData/metrics/{uid}/{document} 上有一个活动设置,你可以在这里看到:
请注意,触发器不包含前导/。在我的第一次部署中,它也没有在代码中指定它。当我第一次测试时没有看到调用时,我改变了它,但是那里的 console.firebase.google.com 中的文本没有改变......但是,随后的部署看起来确实完成了:
=== Deploying to 'THIS PROJECT'...
i deploying functions
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing . directory for uploading...
i functions: packaged . (172.19 KB) for uploading
✔ functions: . folder uploaded successfully
i functions: updating Node.js 8 function onAddLocation(us-central1)...
i functions: updating Node.js 8 function onAddMetric(us-central1)...
✔ functions[onAddLocation(us-central1)]: Successful update operation.
✔ functions[onAddMetric(us-central1)]: Successful update operation.
✔ Deploy complete!
Please note that it can take up to 30 seconds for your updated functions to propagate.
Project Console: https://console.firebase.google.com/project/THIS PROJECT/overview
✨ Done in 51.23s.
我们还可以看到我的示例应用正在那里添加数据:
但是当我添加数据时,我没有看到我的函数被触发。功能 -> 使用选项卡上的计数仍为 0,甚至在几分钟后:
我的函数在节点 8 中并使用 async/await,但是 package.json 和 firebase.json 都指定了
"engines": {
"node": "8"
},
注意事项:
添加了用法选项卡的屏幕截图,显示console.log 可能不会说什么。
【问题讨论】:
-
您可以在函数中使用
console.log(),然后单击函数仪表板中的“日志”选项卡以验证它们是否被触发。事件发生后通常需要大约 30 秒才能看到 Web 仪表板中显示的日志。 -
@miles_b
console.log调用可能需要在它们发生之前调用该函数.. 我在某种程度上错了吗??
标签: firebase google-cloud-firestore google-cloud-functions