Firestore error when setting new document data - firebase

This is not my first time trying to do this in an app but it is the first time I've run into an error like this. Here is the code I'm using to set the data:
final firestore = FirebaseFirestore.instance;
firestore.collection('users').doc(uid).set({
'username': usernameController.text,
'snapchat': snapController.text,
'email': emailController.text,
});
I've tried using the most recent plugin along with older versions but get the same error no matter what. The error seems to mean there's implementation missing for the set function but I don't see how that is possible across multiple versions. Everything firebase-related has been initialized in the app by this point and I am able to use authentication so I don't know what the issue is. Here's the error I get.
Unhandled Exception: MissingPluginException(No implementation found for method DocumentReference#set on channel plugins.flutter.io/firebase_firestore)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
I've also tried flutter clean and then flutter packages get but that did not solve the issue.

It turns out that the project was using a pretty old version of dart. It is a project that I am taking over so I had no idea and that is why the newer plugins could not work properly. After upgrading the dart version, all plugins, and fixing all of the no longer supported code, firestore works fine.

Related

Cannot enable Firestore for this project An unknown error occurred

I'm trying to create fresh Firestore project from my Firestore console, but I get this error, anyone knows how to fix?
Just realized the issue was caused by my CORS(Cross-Origin Resource Sharing), so I turned it off and it got fixed.

Cloud Functions Deployment Error build step 3

Just recently I am starting to experience an issue when trying to deploy my functions through Firebase. When running the command firebase deploy --only functions one of my four functions deploy correctly, but the other three throw this error in the firebase-tools console:
Deployment error.
Build failed: Build error details not available. Please check the logs at url to my GCP logs
When I look at the logs the error message that shows for each function that is failing is:
ERROR: build step 3 "us.gcr.io/fn-img/buildpacks/nodejs10/builder:nodejs10_20200922_20_RC00" failed: step exited with non-zero status: 46
I have searched and googled for quite a while now and I cannot find anyone reporting the same error code, having the same non-zero status returned, or having functions fail on step 3. There doesn't seem to be much for documentation on troubleshooting the errors either.
Hopefully someone here can point me in the right direction.
Thanks!
The error seems to be caused by a missing (or not accessible) file in the history/restore functionality of Firebase. Don't know the reason for this.
A workaround that worked for me was:
Remove the functions in the web console
Deploy normally > firebase deploy
Answering since I can't comment in response to xaphod, Markus's fix worked for me, thank you mate! Deleting the function means it creates a new one rather than trying to restore it, which is the failed step 3 in the build process.
In response to xaphod, I did setup a lifecycle rule for old files in the artifacts bucket, it was by far my biggest bucket in storage and was pushing the free tier limit. I set it up a bit short probably, delete 5 days after last updated time, but surprisingly didn't run into this issue until today (possibly because I usually just deploy them all whenever I update one). I removed the lifecycle rule for now, although I'd rather it not run up the storage space again, I might end up contacting support to see if there's a way to lifecycle them without deleting the most recent, not sure why it doesn't just clear out the old images on updates though.
Found the post that suggested setting up lifecycle rules, firebase storage artifacts is huge, and did some testing as well, deleted all the files in us.artifacts and deployed all my functions (got errors on all them, only deleted the function that I needed to update earlier and deployed it by itself). Doesn't cause any errors, just takes a bit longer, so I think the issue can be fixed by deleting them all or deleting nothing, probably going to set the lifecycle rule to delete immediately and deal with the increased deploy time, rather than the cost of firebase storage.

E/FirebaseInstanceId( 5789): Topic sync or token retrieval failed on hard failure exceptions: AUTHENTICATION_FAILED. Won't retry the operation

While trying to connect Android Studio with a flutter project to Firebase, this error code appeared. After doing A LOT of research, I tried to change my thing, but none seemed to work. I changed my emulator from API 28 to 26 to R, with Nexus 5X which supports Google Play Services. Afterwards, I also added firebase_auth code and cloud_firestore code to pubspec.yaml but it didn't work either. I also tried to change the emulator to Cold Boot but that didn't help. I am really stuck, please HELP!!! Thx :)
Per GitHub post, this error is actually not related to Flutter. In fact, there is an open GitHub issue in Firebase regarding this error. You can check the recommended workarounds here.

Why am I no longer able to deploy functions (Error 503)?

No longer able to deploy cloud function via "firebase deploy" command - receiving error: "HTTP Error: 503, The service is currently unavailable"
I previously had a single function deployed and working until a slight modification was causing an authentication error, so I temporarily deleted it until I had time to fix the error.
So a couple days pass, I modify the original code (just added a bit of code relating to service account credentials, didn't even modify the actual function) and tried to re-deploy it (using 'firebase deploy') however it's throwing the following error: "HTTP Error: 503, The service is currently unavailable".
I thought maybe the service is currently down, but Firebase Status Dashboard shows all services are green and noone else seems to be complaining about this error at the moment. I've tried reinstalling/updating firebase-tools and even reverting the functions index.js code back to what it had been when I last successfully deployed, but same error every time. I don't think it has anything to do with the code on my end, but perhaps some weird bug relating to my account/api/authentication.
I've submitted a tech support question on firebase and am awaiting response, but thought I'd try my luck here as well.
Any suggestions?
After some back and forth with firebase technical support, turns out it is some strange bug on their server end (in relation to this particular project) as I'm able to deploy the same functions no problem to other projects. It may have been "triggered" initially by hitting a function invocation quota when I was having issues with one of the functions in the past (an issue which somehow caused the function to be repeatedly called until I realized and deleted it 2 days after). However the project should no longer be limited and I still am unable to deploy any functions on that particular project.
The issue has been handed onto their engineers and hopefully will have it resolved on their end soon.

Firebase Functions: "Failed to get status of functions deployments"

I am getting a very strange error when I attempt to deploy my firebase functions.
As a test to rule out my code, I deleted everything except the require(firebase-functions); statement in my index.js file and then tried to deploy, but I again received the same error message:
Error: Failed to get status of functions deployments.
It also prompts me to see my function log file, but there is nothing new or relevant outputted there. Anyone have any idea how to fix this?
Please be sure you have the right nodejs version. Also for any issue regarding firebase product, the status can be checked in this link:
https://status.firebase.google.com/
The above link will provide a status for each service.
When the issue gets solved, you can just deploy your functions again with a different name instead of deleting or just redeploy them.
Edit:
Currently in the link above the issue is listed there, there is currently Service Disruption.
Please check this:https://status.firebase.google.com/incident/Functions/18003
to know when this issue will be solved as the firebase team has seen that there is a problem.
firebaser here
There is an ongoing issue with deploying Cloud Functions through the Firebase CLI. To track its status, look a the Firebase status page.
Update: the issue was fixed at 7:22 am PST.
I just successfully deployed some of my own functions, which was failing earlier. Thanks for your reports and patience everyone!
I was getting this error when there were no deployment issues mentioned on the status page.
It turned out that the project just needed to "Link a billing account".
This can be done via the Billing section on Google Cloud Platform.

Resources