Identifying crashes at launch

If your app crashes whilst it is launching, you may want to give the crash more attention. BugSnag provides an API to mark events that occur during startup and also allows you to detect recurrent launch crashes.

Controlling the launch period

By default, BugSnag will treat crashes that occur during the first 5 seconds after calling Bugsnag.start() as having occurred during launch. Events that occur during the app launch have their app.isLaunching property set to true.

To modify this launch time period, use the Launch Duration configuration option. You can also manually indicate that your app has finished launching:

Bugsnag.markLaunchCompleted()

To disable the automatic ending of the launch period, set the Launch Duration configuration option to 0 — in this case the app will be considered to be launching until Bugsnag.markLaunchCompleted() is called.

Bugsnag.start({
  launchDurationMillis: 8000
})

// Once your app has finished launching
Bugsnag.markLaunchCompleted()

Bugsnag.markLaunchCompleted() must be called in the main process (not a renderer process).

Recovering after launch crashes

After a launch crash, it may be appropriate to take some actions in your app, such as removing cached data or resetting some persistent state, to make another one less likely to occur.

if (bugsnag.lastRunInfo && bugsnag.lastRunInfo.crashedDuringLaunch) {
    // Enable "safe mode"
}

The lastRunInfo object contains the following properties;

property type description
consecutiveLaunchCrashes Number The number of consecutive runs that have ended with a crash while launching.
crashed Boolean true if the previous run crashed.
crashedDuringLaunch Boolean true if the previous run crashed while launching.