flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[📚] Crashlytics recordFlutterFatalError

Open ftognetto opened this issue 3 years ago • 2 comments

Hello, on the new documentation of crashlytics https://firebase.google.com/docs/crashlytics/get-started it is written to use

FlutterError.onError = FirebaseCrashlytics.instance.**recordFlutterFatalError**;

instead on https://pub.dev/packages/firebase_crashlytics it is written to use

FlutterError.onError = FirebaseCrashlytics.instance.**recordFlutterError**;

I always used the second one but on the new documentation it use recordFlutterFatalError and this is causing me a lot of trouble on the crashlytics dashboard because every error is marked as a crash.

Why then? Thank you

ftognetto avatar Jun 01 '22 06:06 ftognetto

I came here to ask this very question.

We recently upgraded our various FlutterFire plugins, changed our implementation to match the new documentation and now everything is being logged as fatal.

My main.dart looks like this:

void main() async {
  await runZonedGuarded(() async {
    // Initialise Firebase before rendering the app, see: https://firebase.flutter.dev/docs/overview/#initializing-flutterfire
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp();
    // Error logging
    FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
    Isolate.current.addErrorListener(RawReceivePort((pair) async {
      final List<dynamic> errorAndStacktrace = pair;
      await FirebaseCrashlytics.instance.recordError(
        errorAndStacktrace.first,
        errorAndStacktrace.last,
      );
    }).sendPort);
    // Get cracking
    runApp(MyApp());
  }, (error, stack) {
    FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
  });
}

Possibly related: #8779

oodavid avatar Jun 15 '22 18:06 oodavid

My main.dart looks like this:

@oodavid is

    Isolate.current.addErrorListener(RawReceivePort((pair) async {
      final List<dynamic> errorAndStacktrace = pair;
      await FirebaseCrashlytics.instance.recordError(
        errorAndStacktrace.first,
        errorAndStacktrace.last,
      );
    }).sendPort);

Actually working for you?

I'm getting compilation errors -

image

maximveksler avatar Aug 09 '22 16:08 maximveksler

Having the same issue, I might switch back to recordFlutterError since I do not want the errors marked as crashes

niklaesAtMonta avatar Aug 11 '22 08:08 niklaesAtMonta