[英]is it possible to use setTimeout() in firebase cloud functions?
i am wondering if it is possible to use setTimeout() in cloud functions我想知道是否可以在云函数中使用 setTimeout()
let millisecond = (day *24*60*60*1000) + (hour* 60*60*1000) + (min *60*1000) + (second *1000);
setTimeout(() => {
admin.firestore().doc("timer/" + chatroom).set({
"millisecond":millisecond,
"username":username,
"tousername":tousername,
"day":day,
"min":min,
"second":second,
"hour":hour,
}, millisecond);
if not possible is there a way to accomplish this idea?如果不可能,有没有办法实现这个想法? also am i billed as much as the function is active?
function 活跃时我是否也需要支付费用? thank you
谢谢你
Using setTimeout
in a Cloud Function is possible, but keep in mind that:在 Cloud Function 中使用
setTimeout
是可能的,但请记住:
So if you need to wait for significant time (I usually use 30s as a threshold for this), consider using another mechanism to delay operations such as scheduling a callback with Cloud Tasks .因此,如果您需要等待很长时间(我通常使用 30 秒作为阈值),请考虑使用另一种机制来延迟操作,例如使用 Cloud Tasks 安排回调。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.