Firebase 函数已完成,状态为:错误
Firebase Functions Finished with status: error
我正在编写我的第一个 Firebase 函数,它应该在新用户注册时创建一个包含内部文档(在 Firestore 中)的集合。我得到的唯一日志如下:
Function execution started
和
Function execution took 194 ms. Finished with status: error.
依赖的版本:
"firebase-admin": "^10.0.2",
"firebase-functions": "^3.20.0"
这是我的代码:
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
const db = admin.firestore();
exports.newUser = functions.auth.user().onCreate((user) => {
return db
.collection("users")
.doc(user.uid)
.create(JSON.parse(JSON.stringify(user)));
});
当我尝试使用
在日志中输出 user.uid 时
return functions.logger.log(user.uid);
我得到了预期的结果,因为它按要求输出了 uid,这意味着问题不在于获取用户。
我已阅读,但它并没有解决我的问题。有什么想法吗?
我写这篇文章是为了以后遇到同样问题的任何人!我给 firebase 支持写了一封电子邮件,他们给了我以下答案:
Regarding this same error, we have received a couple of similar reports these past few days.
和
There is already an escalation placed for this.
我遇到了同样的错误,因为我使用命令:“firebase deploy”来部署函数,但是当我使用命令:“firebase deploy --only functions”时,函数部署成功。
我正在编写我的第一个 Firebase 函数,它应该在新用户注册时创建一个包含内部文档(在 Firestore 中)的集合。我得到的唯一日志如下:
Function execution started
和
Function execution took 194 ms. Finished with status: error.
依赖的版本:
"firebase-admin": "^10.0.2",
"firebase-functions": "^3.20.0"
这是我的代码:
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
const db = admin.firestore();
exports.newUser = functions.auth.user().onCreate((user) => {
return db
.collection("users")
.doc(user.uid)
.create(JSON.parse(JSON.stringify(user)));
});
当我尝试使用
在日志中输出 user.uid 时return functions.logger.log(user.uid);
我得到了预期的结果,因为它按要求输出了 uid,这意味着问题不在于获取用户。
我已阅读
我写这篇文章是为了以后遇到同样问题的任何人!我给 firebase 支持写了一封电子邮件,他们给了我以下答案:
Regarding this same error, we have received a couple of similar reports these past few days.
和
There is already an escalation placed for this.
我遇到了同样的错误,因为我使用命令:“firebase deploy”来部署函数,但是当我使用命令:“firebase deploy --only functions”时,函数部署成功。