#Flutter SDK behavior on errors from appRunner within Sentry.init

7 messages · Page 1 of 1 (latest)

wispy sphinx
#

Hi there, our customer reported the app not starting. I was puzzled to not see anything in Sentry. Looking through the SDK code, it seems like it's only printed but never reported when caught by Sentry? What's the recommend approach to handling main()/startup errors here?

potent stone
wispy sphinx
# potent stone hey, could you share your init setup? do you do any processing before SentryFlut...

There's nothing before SentryFlutter.init, everything happens inside appRunner. An async method failed in this case. The main method looks like this:

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SentryFlutter.init(
    configureSentry,
    appRunner: () async {
      final transaction = Sentry.startTransaction(
        'app_startup',
        'task',
        bindToScope: true,
      );

      try {
        await _startApp(span: transaction);
      } finally {
        await transaction.finish();
      }
    },
  );
}
#

Note: in _startApp, it didn't make it to any runApp(). It failed in-between.

potent stone
#

I just tried to repro this and it successfully manages to report the unhandled exception (tested on Android & Web)

by the time appRunner is executed the SDK is ready to catch and report events.

I think I need more info here, which platform are you targeting?

  await SentryFlutter.init(
    (options) {
      options.dsn = exampleDsn;
    },
    appRunner: () async {
      throw Exception('test');
      runApp(
        // ...
      );
    },
  );
wispy sphinx
#

Ok I found the actual problem...

#

I had a return null; in a beforeSend handler 🤦