我正在使用具有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领域的初学者,我一直在尝试找出以下代码的问题所在,但是我以所有可能的方式失败了。
该代码应该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