reportBootstrapDiagnostic function

void reportBootstrapDiagnostic(
  1. Object error,
  2. String message, [
  3. StackTrace? stackTrace
])

Reports a bootstrap-time diagnostic that may fire BEFORE the error reporter is attached, ensuring every consumer's backend captures it.

The appInitFirebase hang-recovery fires at the Firebase step. A custom reporter that attaches before Firebase (e.g. Sentry via attachErrorReportingFirst) is already live then, so this reports immediately. A Firebase Crashlytics consumer does not attach until the post-Firebase step, so this DEFERS the report and appInitErrorHandling flushes it on attach — closing the "Crashlytics recovers silently" gap.

Non-throwing; safe to call any number of times. Deferred reports are capped (drop-oldest) like the early buffer so a pre-attach loop can't grow it unbounded.

Implementation

void reportBootstrapDiagnostic(Object error, String message, [StackTrace? stackTrace]) {
  if (_errorHandlingAttached) {
    loge(error, message, stackTrace);
    return;
  }
  _deferredBootstrapReports.add(_DeferredBootstrapReport(error, message, stackTrace));
  while (_deferredBootstrapReports.length > _earlyErrorBufferCap) {
    _deferredBootstrapReports.removeAt(0);
  }
}