0
我想知道如果使用process.exit()
是停止執行雲端函數的有效方法(或好主意)。它允許編寫稍乾淨的代碼,因爲您不必從導出的函數中顯式返回。在Google雲端函數中使用process.exit
exports.myFunction = function myFunction(req, res) {
const abort = function(err) {
console.error(err);
res.status(500).send();
process.exit(1);
};
doSomething(err => {
if (err) abort(err);
res.status(200).send("Success!");
});
};
我投票結束這個問題作爲題外話,因爲它屬於codereview.stackexchange.com –