javascript - 直接调用 Firebase Cloud 函数时出现内部错误
问题描述
尝试直接调用 Firebase Cloud Function 时出现以下错误:
Error: internal
at new HttpsErrorImpl (error.ts:65)
at _errorForResponse (error.ts:175)
at Service.<anonymous> (service.ts:276)
at step (tslib.es6.js:102)
at Object.next (tslib.es6.js:83)
at fulfilled (tslib.es6.js:73)
我注意到用户过去曾遇到过类似的问题,即 Firebase 版本 7.22.0 导致它,并且它在 7.22.1 中得到解决,但我使用的是 8.3.0,所以这应该不是问题。
我的云功能永远不会被触发,我在 Firebase 功能日志中看不到任何错误。
这是我的客户端功能:
async function testCallFunction() {
const callTest = functions.httpsCallable('callTest');
return await callTest({ companyId: coRef })
.then((result) => {
console.log(result)
}).catch(err => {
console.log(err)
})
}
这是我的云功能:
exports.callTest = functions.https.onCall((data, context) => {
console.log('Call Test Fired')
return admin.firestore().collection('users').doc(context.auth.uid).get()
.then((doc) => { return doc.data()})
.catch(err => {throw new functions.https.HttpsError(err.message)})
})
但它永远不会到达云功能,我只收到内部错误,云功能日志中没有日志。
我不确定我做错了什么?我已确保我使用的是最新的 firebase JS SDK (8.3.0),并且我已尝试尽可能地贴近文档。有什么明显的我做错了吗?
谢谢
解决方案
我在使用AngularFireFunctions httpsCallable 方法时看到了完全相同的症状。最近将 firebase sdk 从 8.2.4 更新到 8.3.1,我怀疑这会引入 https 可调用内部错误。降级到 8.2.4 解决了这个问题:
npm install firebase@8.2.4 --save
推荐阅读
- express - Sails 1.x 使用自定义路由插入 3 方中间件
- javascript - 如何限制只允许整数特别是数千的文本框?
- sql - 如何在表格中添加一系列数据?
- python-3.x - 使用仿射变换映射点集
- jquery - 未捕获的类型错误:$(...).live 不是函数
- node.js - 为什么不在 Nodejs 中使用 import 而使用箭头函数
- python - 无法在多个字段上应用搜索 Django
- swift - 显示最近的消息未定义符号:_OBJC_CLASS_$_SFAuthenticationSession
- html - 如何在 VSCode 中将所有 HTML 属性设置为斜体?可能吗?
- javascript - 使用 Javascript 处理复数的不同方法是什么以及如何支持本地化?