由于几天后我无法在本地测试云功能,因为所有写入功能都没有执行而且没有返回任何内容,因此该功能会挂起并最终因超时而停止。
示例功能:
import { database as dbEvent } from "firebase-functions";
export default dbEvent.ref("/tariffs/removeHistory").onCreate((event: any) => {
console.log("START");
const bikesHistoryRef = event.data.adminRef.parent.parent.child("bikesHistory");
return bikesHistoryRef.set(null).then((res) => console.log("Delete done", res));
});
结果:
firebase > removeBikeHistory("test")
'Successfully invoked function.'
firebase > info: User function triggered, starting execution
info: START
firebase >
firebase > info: Execution took 61023 ms, finished with status: 'timeout'
info: Execution took 49694 ms, finished with status: 'crash'
任何建议有什么问题?我的所有云功能都会发生这种情况,当我部署它们时,它就可以运行。
我尝试过:
firebase-admin@5.5.1
firebase-functions@0.7.3
firebase-tools@3.15.4 (-g)
和
firebase-admin@5.6.0
firebase-functions@0.7.5
firebase-tools@3.16.0 (-g)
编辑:
启用日志记录后,我收到以下错误:
info: 0: onDisconnectEvents
info: p:0: Making a connection attempt
info: p:0: Failed to get token: Error: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: invalid_grant (Bad Request)". There are two likely causes: (1) your server time is not properly synced or (2) your certificate key file has been revoked. To solve (1), re-sync the time on your server. To solve (2), make sure the key ID for your key file is still present at https://console.firebase.google.com/iam-admin/serviceaccounts/project. If not, generate a new key file at https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.
p:0: data client disconnected
info: p:0: Trying to reconnect in 1283.8299240003184ms
0: onDisconnectEvents
我在安装较旧的firebase-function / admin版本时实际上看到了这个错误,但是认为通过安装新版本来修复它。我该如何解决?
答案 0 :(得分:0)
我在此错误报告中找到了解决方案: https://github.com/firebase/firebase-functions/issues/135
我删除了以下文件,现在我的云功能再次在本地工作:
rm ~/.config/gcloud/application_default_credentials.json