I'd like to know if using process.exit()
is a valid way (or good idea) to stop the execution of a Cloud Function. It allows one to write slightly cleaner code, in that you don't have to explicitly return from the exported function.
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!");
});
};
via Wayne Ashley Berry
No comments:
Post a Comment