I am writing my first Firebase Function that is supposed to make a collection with a document inside (in Firestore) when a new user registers. The only logs I am getting are the following:
Function execution started
and
Function execution took 194 ms. Finished with status: error.
The versions of the dependencies:
"firebase-admin": "^10.0.2", "firebase-functions": "^3.20.0"
This is my code:
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))); });
When I tried outputting the user.uid in the logs with
return functions.logger.log(user.uid);
I got the expected results as it output the uid as requested, meaning that the problem isn’t with getting the user.
I have read this question, but it didn’t solve my problem. Any ideas?
Advertisement
Answer
I am writing this for anyone that comes across the same problem in the future! I wrote an email to the firebase support, they gave me the following answer:
Regarding this same error, we have received a couple of similar reports these past few days.
and
There is already an escalation placed for this.
Update: They have already fixed the issue.