Firestore update is crashing app - firebase

let dataRef = database.collection("stores").document(store.id).collection("data").document("storeData")
var storeData: [String:Any] = [:]
storeData["seq"] = store.seq + 1
storeData["shiftSeq"] = store.shiftSeq + 1
dataRef.updateData(storeData)
I am receiving the following error when executing the above code. It was working fine until I upgraded to the latest version of Firebase/Firestore
* Assertion failure in -[FSTWriteStream startWithDelegate:], third_party/firebase/ios/Source/Firestore/Source/Remote/FSTStream.m:244
2017-12-08 10:48:47.819586-0500 centroOne[1833:473631] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: Delegate must be nil'

I removed a rule set that was attached to this document and the problem went away. The ruleset referenced a value in another document to make sure it existed.

I've faced this problem in swift recently and solved my problem by checking if documentId exists. In above case, please check store.id exits in your Firestore db and then run update method.

Related

Failed to generate manifest from function source: Error: Service account object must contain a string "private_key" property

I got this error after running npm run serve,
!! functions: Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: Error: Service account object must contain a string "private_key" property.
Heres the screenshot of the logs
it seems service account issue heres my initialization
admin.initializeApp({ credential: admin.credential.applicationDefault(), });
i found the solution by commenting all of my codes , then theres new errors says , index.js not found , since im using typescript , and then i realised that im running the firebase deploy functions command using the wrong lib folder generated by typescript,
thats why i got these 2 erros:
Failed to generate manifest from function source: Error: Service account object must contain a string "private_key" property.
RangeError: Maximum call stack size exceeded.

Can't remove values in Firebase realtime Database

I want to remove a node (~13mb) from my realtime database. I use cli with firebase database:remove '/node' but i am getting An unexpcted error. Debug file says:
[debug] [2020-09-30T10:17:16.845Z] TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
at validateString (internal/validators.js:122:11)
at Url.parse (url.js:159:3)
at urlParse (url.js:154:13)
at Url.resolve (url.js:667:29)
at Object.urlResolve [as resolve] (url.js:663:40)
at Object.getDatabaseUrl (/usr/local/lib/node_modules/firebase-tools/lib/utils.js:62:26)
at Command.actionFn (/usr/local/lib/node_modules/firebase-tools/lib/commands/database-remove.js:33:32)
at Command.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/command.js:166:25)
at Generator.next (<anonymous>)
at fulfilled (/usr/local/lib/node_modules/firebase-tools/lib/command.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
When i do a firebase database:get '/node' i am getting the correct values.
I already updated firebase-tools and did a new init.
I experienced a similar problem today and submitted this as an issue on the firebase-tools GitHub:
https://github.com/firebase/firebase-tools/issues/2667
I manually added a trivial key to the database and firebase database:remove had the same problem attempting to remove it.
Hopefully others there can reproduce and solve it.
(I would have commented this if I had the reps... But perhaps watching the issue get addressed over there is the true answer anyway 🤷)
Edit: Resolved with Changelog for database:remove command fix #2658 merged into master and released in version 8.12.0 -
Works great 👍

Flutter firebase - can't catch exception thrown white trying to update a document with a map with an empty key

While trying to update a document in Firestore with a map with an empty key (a bug in my code), I wasn't able to catch the exception, which resulted in an app crash.
Here's a sample code:
try {
Map<String, dynamic> crash = {"": 3}; // this is an empty key (bug)
await docRef.collection('collection').document('doc').updateData({"ABC": crash});
} catch (err) {
print(err);
}
The exception (quite reasonable):
*** Assertion failure in auto firebase::firestore::model::FieldPath::FromServerFormat(const absl::string_view)::(anonymous class)::operator()() const(), /project/ios/Pods/FirebaseFirestore/Firestore/core/src/firebase/firestore/model/field_path.cc:90
Lost connection to device.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: Invalid field path (s3SEDn5nhnWiqeZjpDmY.``). Paths must not be empty, begin with '.', end with '.', or contain '..' (expected !segment.empty())'
I don't see the error printed to the console, nor I get to a breakpoint set there.
My questions / issues:
Am I using the try catch block in a wrong way? Why isn't the catch statement working?
After the app crashes, trying to relaunch it fails, with the following error:
FileSystemException: Getting current working directory failed, path = '' (OS Error: Too many open files in system, errno = 23)
Only uninstalling and reinstalling the app works.
Any idea if this is normal? If not, what can I do about it?
Crashes both on iOS and Android,
Firestore plugin version cloud_firestore: ^0.12.7
I had a similar issue trying to catch exeptions on updateData with a map with no internet connection (emulator).
await Firestore.instance.collection('collection').document(doc).updateDataa({"ABC": crash}).timeout(Duration(seconds: 10));
This was the only way i could handle the timeout and return connection error!

Firebase Cloud Functions Shell not executing write operations on realtime database

Since a few days I am not able to test cloud functions locally anymore, as all write functions are not executed and nothing is returned, consequently the function hangs and eventually stops with a timeout.
Example function:
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));
});
Result:
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'
Any suggestion what is wrong? This happens with all my cloud functions, and when I deploy them it works.
I have tried with:
firebase-admin#5.5.1
firebase-functions#0.7.3
firebase-tools#3.15.4 (-g)
and
firebase-admin#5.6.0
firebase-functions#0.7.5
firebase-tools#3.16.0 (-g)
EDIT:
After enabling logging I get the following errors:
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
I have actually seen this error when I installed an older firebase-function/admin version, but thought it got fixed by installing the newer version. How can I fix it?
I found the solution in this bug report:
https://github.com/firebase/firebase-functions/issues/135
I have deleted the following file, now my cloud functions work locally again:
rm ~/.config/gcloud/application_default_credentials.json

CorePlot SIGABRT runtime error xcode4

I've modified the code at http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application to run on xcode4, I have a view that I put into my ConsoleViewControllor.xib with its class as CPTGraphHostingView.
Compiles great, at runtime however, I get a SIGABRT at line
hostingView.hostedGraph = graph; with the error
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x5910d40'
* Call stack at first throw:
Anyone else run into this issue? I'm more than willing to give you code and answer more questions. Thanks in advance!
Check the setup in your .xib again. -[UIView setHostedGraph:] means that Xcode created a UIView, not a CPTGraphHostingView.

Resources