Kyl*_*iss 25 firebase google-cloud-functions
我使用HTTP Firebase Cloud功能每次运行都会出现此错误:
Function execution took ****ms, finished with status: 'connection error'
它发生的不一致,但我不能完全解决问题所在.我不相信错误在我的应用程序中,因为它没有显示错误打印输出.在运行此云功能时,我自己与firebase的连接并没有消失.
任何想法为什么Firebase随着"连接错误"随机失败云功能执行?
Jef*_*eff 25
Function execution took ****ms, finished with status: 'connection error' 有两个主要原因:
几个未回复的承诺的例子:
exports.someFunc = functions.database.ref(‘/some/path’).onCreate(event => {
let db = admin.database();
// UNRETURNED PROMISE
db.ref(“/some/path”).remove();
return db.ref(“/some/other/path”).set(event.data.val());
});
Run Code Online (Sandbox Code Playgroud)
exports.makeUppercase = functions.database.ref('/hello/{pushId}').onWrite(event => {
return event.data.ref.set('world').then(snap => {
// UNRETURNED PROMISE
admin.database().ref('lastwrite').set(admin.database.ServerValue.TIMESTAMP);
});
});
Run Code Online (Sandbox Code Playgroud)
exports.makeUppercase = functions.database.ref('/hello/{pushId}').onWrite(event => {
// UNRETURNED PROMISE
event.data.ref.set('world').then(snap => {
return admin.database().ref('lastwrite').set(admin.database.ServerValue.TIMESTAMP);
});
});
Run Code Online (Sandbox Code Playgroud)
要在部署代码之前帮助捕获此错误,请查看此eslint规则.
要深入了解promises,以下是一些有用的资源:
即使此问题的答案已获批准,您也可能已按照该答案中的步骤操作,但仍然会出现错误。
在这种情况下,GCP 通知我们 Node 8 CF 存在一个已知问题和此连接错误,解决方法是将节点版本更新为 10。
相关 github 问题:https : //github.com/firebase/firebase-functions/issues/429
具体评论:https : //github.com/firebase/firebase-functions/issues/429#issuecomment-577324193
| 归档时间: |
|
| 查看次数: |
10335 次 |
| 最近记录: |