I was running my cloud functions locally with the emulator no problems yesterday. When I came back and set my export GOOGLE_APPLICATION_CREDENTIALS=after a reboot I now cannot read or write to the database. I've deleted my key, created a new one and I still run into the same problem. I've created a simple function that runs with no errors yet it doesn't read or write to the database when ran in the emulator. The .get() function says it couldn't find anything and the .set() doesn't return anything nor does it write to the DB.
Edit* my functions do run when deployed to firebase, but I have one that parses and loads huge amounts of data that times out that I have to run locally because of how long it takes.
exports.dumbFunction = functions.https.onRequest((request, response) => {
admin
.firestore()
.collection("test")
.doc("hello")
.get()
.then(function(doc) {
if (doc.exists) {
console.log("You got me" + doc.data());
} else {
console.log("I couldn't find anything");
}
});
admin
.firestore()
.collection("test")
.doc("test123")
.set({
setme: "ok",
asdf: "asdf"
})
.catch(err => {
console.log("did I error?");
console.log(err);
});
console.log("hi again");
});
I've followed the instructions of the following.
https://cloud.google.com/docs/authentication/getting-started
https://firebase.google.com/docs/functions/local-emulator
https://cloud.google.com/storage/docs/reference/libraries
when I run the node.js example in the third link I get the following error messages which I think is my issue but I have no idea why or how to fix this.
Unknown network resource requested!
- URL: "http://metadata.google.internal./computeMetadata/v1/instance"
ERROR: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at GoogleAuth.<anonymous> (/home/ben/Development/polity/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:168:23)
at Generator.next (<anonymous>)
at fulfilled (/home/ben/Development/polity/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:19:58)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
when I echo $GOOGLE_APPLICATION_CREDENTIALS it shows that it's set to my JSON file containing my key.
The Unknown network resource requested! is something I see on my other functions as well now which is something I didn't receive when they were working.
Any idea?
Much thanks
response.sendStatus(200);out of my example, I forgot to remove it. Even without sending a response it still doesn't work. That function is just an example of a larger issue that happens with all my functions locally ran now. - Onyoursix