我正在使用具有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完成之前发送邮件已经完成了,所以我想知道终止进程是如何工作的以确保代码不会打破.
我正在研究云功能,尤其是计划功能。我需要每 5 分钟定期触发一个功能,但仅在测试步骤中。我需要在 pubsub 模拟器上运行它而不部署它。
怎么做?
我尝试使用 firebase shell,但它只触发了一次
exports.scheduledFunctionPlainEnglish =functions.pubsub.schedule('every 2 minutes')
.onRun((context) => {
functions.logger.log("this runs every 2 minutes")
return null;
})
Run Code Online (Sandbox Code Playgroud) javascript firebase google-cloud-pubsub google-cloud-functions