firebase - Cloud Function 失败并显示消息“错误:函数在请求范围外崩溃”
问题描述
我无法让最简单的 Firebase Cloud Function 正确执行。下面的代码不会产生任何控制台日志记录,除了错误: Error: function crashed out of request scope
和Function invocation was interrupted.
exports.testFunction = functions.firestore.document('trigger/dummy2').onUpdate(async (change : any, context : any) => {
console.log( "How can this fail?" );
});
解决方案
这在文档中并不明显(至少对我而言),但async
函数需要返回一个 Promise。如果这是不相关的要求,您可以返回已解决的承诺。
exports.testFunction = functions.firestore.document('trigger/dummy2').onUpdate(async (change : any, context : any) => {
console.log( "How can this fail?" );
return Promise.resolve(100);
});
推荐阅读
- python - 包含三个连续的辅音
- c# - 如何使用 moq 验证具有参数类型(字符串、对象)的函数
- javascript - 如何在 JavaScript 中提取自定义 HTTP POST 请求标头,以便在另一个 POST 请求中传输?
- spring-mvc - 无法在 Tomcat Web 应用程序管理器中启动 Spring Web 应用程序
- c++ - openssl 命令加密数据不匹配 EVP_aes_128_cbc C 代码
- javascript - 将 redis 键组合成响应
- r - 如何在 R 中使用 gt() 制作表格?
- reactjs - 在 firebase 中“导入您打算使用的单个 SDK 组件”是什么?
- python - Python/VPN:如何在 VPN 重新连接后自动恢复 python 脚本?
- vue.js - 如何从 Bootstrap-vue 的 b-form-timepicker 组件返回日期格式从 HH:mm:ss 到 HH:mm