We are using firebase_crashlytics: ^0.4.0+1 in a flutter app. Within the runApp() we are starting to listen to errors and crashes just like mentioned in the documentation.
runZonedGuarded(() {
runApp(
..
}, (error, stackTrace) {
FirebaseCrashlytics.instance.recordError(error, stackTrace);
});
In general crashes are reported, but not for these type of crashes EXCEPTION CAUGHT BY WIDGETS LIBRARY.
In some circumstances objects might be null, but instead of getting a crash reported to the firebase crashlytics dashboard, nothing happens. User only receive a grey screen and that is it.
Therefore we only are notified if a user reports these errors, but we receive no logs.
Is this a non-fatal error and we should be using recordFlutterError method?
BTW, this is being called when the error is thrown:
Function originalOnError = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails errorDetails) async {
await FirebaseCrashlytics.instance.recordFlutterError(errorDetails);
// Forward to original handler.
originalOnError(errorDetails);
Even the method originalOnError(errorDetails) is called the error is not recorded in the firebase crashlytics dashboard.
How can we make these non-fatal errors also be reported?
The logging has been done by firebase crashlytics. The default filter in the firebase console dashboard was set to crashes. Removing the filter and we can see all reported errors, crashes, non-fatal errors.
Thanks to this stackoverflow post
Related
I built this function months ago and has been working fine until two days ago, after updating Flutter (unrelated I presume). The function essentially reviews a users upload photo for inappropriate content before moving the documents for the public to see.
I can see the images and documents uploading correctly from app to Firestore. This then triggers the function which uses vision.ImageAnnotatorClient() to label the images ('#google-cloud/vision'). Almost immediately the function console throws this error:
onCreatePost:
Error: 1 CANCELLED: The operation was cancelled.
at Object.callErrorFromStatus (/srv/node_modules/#grpc/grpc-js/build/src/call.js:30:26)
at Http2CallStream.call.on (/srv/node_modules/#grpc/grpc-js/build/src/client.js:96:33)
at emitOne (events.js:121:20)
at Http2CallStream.emit (events.js:211:7)
at process.nextTick (/srv/node_modules/#grpc/grpc-js/build/src/call-stream.js:97:22)
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
At what level is this cancellation occuring? I don't even know where to narrow down my search to.
How did this happen? Can I expect random functions to fail in the future?
Am I taking crazy pills? Feels like i'm going crazy looking for material on this.
Edit:
I have narrowed the error down to this line in my function:
var [dataTest] = await visionClient.annotateImage(request)
visionClient being an instance of vision.ImageAnnotatorClient();
vision coming from '#google-cloud/vision'
I also noticed that these errors started appearing after an unusual unique error:
onCreatePost
Error: function crashed out of request scope Function invocation was interrupted.
Solved the issue:
I had to go into my Flutter apps functions folder, where I hold my firebase cloud functions. I then had to update 'google-cloud/vision' using the following command:
npm install --save #google-cloud/vision
I deployed the new update to firebase and everything started working again... How am I supposed to catch updates on packages like this changing and breaking my code?
I have integrated Flutter Crashlytics in our app, but it is reporting crashes stack trace in Java class files and not in Dart files. So it is difficult to infer what is the file and line number where this issue occurred in the flutter codebase.
Here is an example of one such crash report from Firebase Crashltytics of an Uncaught exception:
Non-fatal Exception: java.lang.Exception: NoSuchMethodError: The method 'markNeedsBuild' was called on null.
Receiver: null
Tried calling: markNeedsBuild()
at State.setState(State.java:1168)
at _ArgonButtonState.initState.<fn>(initState.java:107)
at AnimationLocalStatusListenersMixin.notifyStatusListeners(AnimationLocalStatusListenersMixin.java:193)
at AnimationController._checkStatusChanged(AnimationController.java:773)
at AnimationController._tick(AnimationController.java:789)
at Ticker._tick(Ticker.java:237)
at SchedulerBinding._invokeFrameCallback(SchedulerBinding.java:1102)
at SchedulerBinding.handleBeginFrame.<fn>(handleBeginFrame.java:1017)
at SchedulerBinding.handleBeginFrame(SchedulerBinding.java:1015)
at SchedulerBinding._handleBeginFrame(SchedulerBinding.java:949)
Here is how Crashlytics is initialized:
// Pass all uncaught errors from the framework to Crashlytics.
FlutterError.onError = Crashlytics.instance.recordFlutterError;
runZoned(() {
runApp(AppMain(homeWidget));
}, onError: Crashlytics.instance.recordError);
I am reporting caught exceptions as such:
Crashlytics.instance.recordError(error, stack);
How can I configure Crashlytics to report stack trace in dart? Does Crashlytics show erroneous file names and line numbers for Dart source code?
Todd from Crashlytics. This is a known behavior and we are looking into possible options moving forward. Kotlin users will see a similar behavior.
I would suggest to move on to Sentry.
I am doing it for my app now. And while just testing it, I can say that sentry is much better than Crashlytics!
My Firestore web app sometimes hits the following error on iOS:
#firebase/firestore: Firestore (5.5.0): INTERNAL UNHANDLED ERROR: An internal error was encountered in the Indexed Database server
What is causing this and how do I fix it?
This is due to a bug in iOS versions >= 12.2 and < 13. See https://bugs.webkit.org/show_bug.cgi?id=197050 for details. The bug can occur when the page or app returns to the foreground after being in the background for some period of time. When the error occurs, IndexedDB is left in an unusable state, causing the Firestore SDK to generate the mentioned error and become unusable as well.
The only way to avoid the error is disabling persistence. If you require persistence to be enabled, the only way to potentially recover is to catch the error with a global window.onerror handler and e.g. refresh the page:
window.onerror = function(error) {
if (error.indexOf("An internal error was encountered in the Indexed Database server") >= 0) {
// Refresh the page to restore IndexedDb to a working state.
window.location.reload();
}
};
More context: https://github.com/firebase/firebase-js-sdk/issues/1670
I want to test out crash report using Firebase Crashlytics in my Flutter App. I need to Fatal crash my flutter app for both Android and iOS programmatically. Any idea?
If you have the flutter_crashlytics plugin, you can test it using
FirebaseCrashlytics.instance.crash();
You should be able to throw a Dart exception by doing this anywhere in your Flutter app:
throw Exception("This is a crash!");
Or by using an arbitrary object:
throw "This is a crash!";
You can find more info about dart exceptions in the language tour and if you want, you can create your own custom Exception type as explained in this SO answer
integrate firebase_crashlytics
Crashlytics.instance.crash();
using firebase_crashlytics plugin
FirebaseCrashlytics.instance.crash();
You should enable crashlytics
void main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
if (kDebugMode) {
FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);//disable false
}else{
FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
}
You can crash you Flutter app by many ways:
throw(Exception('Hello Crashlytics')); like in #Xavi Rigau's answer
List list;
list.add("add");
Like #Paresh Mangukiya does.
3.
final a = [12];
print(a[1]);
But there is 2 IMPORTANT thing you should consider:
You should run your app in release mode, for example with the command flutter run --release
In Crashlytycs console, by default shown only fatal crashes. The crashes above are non-fatal crashes. So, you should clear the filter to see all crash types. (Filter can be filtered in crashlytics dashboard by clicking (x) button near filter). More on this you can read from this SO answer
Check this out . This is from the official documentation. https://firebase.flutter.dev/docs/crashlytics/usage
Once your configuration is proper according to documentation for crashlytics, FirebaseCrashlytics.instance.crash(); will crash the app.
I am implementing Firebase Auth into my Flutter app. How do I access error codes or user friendly error messages from Firebase? Is this available yet?
For example, on iOS you can get the localisedDescription from an error.
In Dart I have a onError: and catchError Futures which return an error object, but don't appear to have the relevant associated information.
it is available. the problem is that the catchError value is not an object, so you can't loop thru its keys. print/debugPrint just outputs the values without giving you any clue how to reference only one of them.
it has getter methods - code, message, and...details. 'details' is the human-readable result, but it's not documented on the firebase_auth flutter example. do this:
}).catchError((e) {
print(e.details); // code, message, details
});