node.js - 我是否需要明确由 Firestore 事件触发的 "end"Firebase Cloud Functions?

标签 node.js firebase google-cloud-platform google-cloud-firestore google-cloud-functions

在 Firebase 的 HTTP 函数中,我们得到:

Terminate HTTP Functions DOC link

Always end an HTTP function with send(), redirect(), or end(). Otherwise, your function might continue to run and be forcibly terminated by the system. See also Sync, Async and Promises.

问题

其他类型的函数(例如由 Firestore 事件触发的函数)是否需要类似的功能?

我是否需要返回某些内容(即使它为空)或其他命令来显式结束它?

最佳答案

Is something similar necessary to other types of functions like the ones triggered by Firestore events?

所有其他类型的云函数(即除 HTTP 云函数之外的所有云函数)都要求您返回一个 promise ,该 promise 将在异步工作完成时解决。这包括后台触发的云函数(例如由 Firestore 事件触发的函数)。

如果您的云函数不包含异步操作,您可以在所有工作完成后返回一个简单的值,例如 null。如果您想要取消 Cloud Function 执行,例如未满足先决条件,您也可以执行此操作。官方 Cloud Functions 示例显示了几个示例,特别是 here一个here .

<小时/>

我建议您观看 Firebase 视频系列中有关“JavaScript Promises”的 3 个视频:https://firebase.google.com/docs/functions/video-series/其中详细解释了这一点。

关于node.js - 我是否需要明确由 Firestore 事件触发的 "end"Firebase Cloud Functions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59561961/

相关文章:

node.js - 使用Sequelize实现单表继承

node.js - 使用 _id 引用时哪个性能最好?使用 _id 检索时,我收到错误 INVALID OBJECT ID

ios - 当数据库字典位于另一个 View Controller 中时,如何将图像 URL 添加到 firebase 数据库

java - FirebaseRecyclerView 无法在 fragment 内工作

ssh - VM 重新启动后无法通过 SSH Google Cloud VM 实例

node.js - 我想在 Microsoft Teams 中垂直显示按钮

node.js - Node 如何在并行功能中使用路由

swift - 先前打开的 VC 的功能触发

google-cloud-platform - 读取数据时出错,错误消息 : CSV table references column position 174, 但从位置开始的行:136868 仅包含 94 列

kubernetes - 在 Google Container Engine 上访问 SkyDNS etcd API 以添加自定义记录