相关疑难解决方法(0)

发送响应后继续执行(Cloudbase for Firebase)

我正在使用具有https触发器的Firebase函数,我想知道在将响应发送到客户端多长时间后,函数仍在执行.我想向客户端发送响应,然后执行另一个操作(发送邮件).目前我这样做如下:

module.exports.doSomeJob = functions.https.onRequest((req, res) => {
    doSomeAsyncJob()
    .then(() => {
        res.send("Ok");
    })
    .then(() => {
        emailSender.sendEmail();
    })
    .catch(...);
});
Run Code Online (Sandbox Code Playgroud)

上面的代码对我有用,但是我怀疑代码只能起作用,因为在res.send完成之前发送邮件已经完成了,所以我想知道终止进程是如何工作的以确保代码不会打破.

firebase google-cloud-functions

11
推荐指数
3
解决办法
1848
查看次数

Firebase函数返回,并且Promise不会退出该函数

我仍然是Firebase领域的初学者,我一直在尝试找出以下代码的问题所在,但是我以所有可能的方式失败了。

该代码应该uid从数据库中的用户概要文件中检索,然后使用它来更新身份验证概要文件,如果身份验证概要文件更新成功,则再次使用它来更新数据库概要文件。

在其中,index.js我定义了一个导出函数来处理HTML表单中的POST参数。下面的代码在另一个模块文件中定义处理程序函数:

 exports.auUpdateUserByEmail = (req, res) => {
  // This handler function will retrieve the POSTed params of user profile
  // and will attempt to update the existing user authentication as well as
  // the database profiles.
  //
  // This function accepts the following params:
  // 1. User email   // 2. Phone number   // 3. password   // 4. Display name
  // 5. Photo url   // 6. Disabled Flag
  //

  var db = admin.firestore();

  var uEmail …
Run Code Online (Sandbox Code Playgroud)

javascript node.js firebase firebase-realtime-database google-cloud-functions

5
推荐指数
1
解决办法
3126
查看次数