【发布时间】:2020-11-24 14:05:35
【问题描述】:
如果我选择不在 firebase 函数内等待异步调用完成,那么当函数完成时异步调用会发生什么情况?它在哪个线程上继续,它是否仍然在函数的 runtimeOpts 内运行,这对使用有何影响?
import * as firebase from 'firebase';
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
exports.action = functions.https.onRequest((req, res) => {
admin.database().ref('action').add({ 1: 2 });
res.end(); // or just `return;` for other functions
});
甚至可能
exports.action2 = functions.https.onRequest((req, res) => {
new Promise(resolve => setTimeout(() => admin.database().ref('action').add({ 1: 2 })}, 10_000));
res.end();
});
【问题讨论】:
标签: firebase google-cloud-functions