diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a317d7a49..637bd1b91c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Use FFI/JNI for `captureEnvelope` on iOS and Android ([#3115](https://github.com/getsentry/sentry-dart/pull/3115)) - Log a warning when dropping envelope items ([#3165](https://github.com/getsentry/sentry-dart/pull/3165)) - Call options.log for structured logs ([#3187](https://github.com/getsentry/sentry-dart/pull/3187)) +- Remove async usage from `FlutterErrorIntegration` ([#3202](https://github.com/getsentry/sentry-dart/pull/3202)) - Tag all spans during app start with start type info ([#3190](https://github.com/getsentry/sentry-dart/pull/3190)) ### Dependencies diff --git a/packages/flutter/lib/src/integrations/flutter_error_integration.dart b/packages/flutter/lib/src/integrations/flutter_error_integration.dart index 4e5965c561..d6a9424e6e 100644 --- a/packages/flutter/lib/src/integrations/flutter_error_integration.dart +++ b/packages/flutter/lib/src/integrations/flutter_error_integration.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/foundation.dart'; import 'package:sentry/sentry.dart'; import '../sentry_flutter_options.dart'; @@ -22,7 +24,7 @@ class FlutterErrorIntegration implements Integration { @override void call(Hub hub, SentryFlutterOptions options) { _defaultOnError = FlutterError.onError; - _integrationOnError = (FlutterErrorDetails errorDetails) async { + _integrationOnError = (FlutterErrorDetails errorDetails) { final exception = errorDetails.exception; options.log( @@ -88,7 +90,7 @@ class FlutterErrorIntegration implements Integration { stackTrace = getCurrentStackTrace(); hint.addAll({TypeCheckHint.currentStackTrace: true}); } - await hub.captureEvent(event, stackTrace: stackTrace, hint: hint); + unawaited(hub.captureEvent(event, stackTrace: stackTrace, hint: hint)); // we don't call Zone.current.handleUncaughtError because we'd like // to set a specific mechanism for FlutterError.onError. } else { diff --git a/packages/flutter/lib/src/integrations/on_error_integration.dart b/packages/flutter/lib/src/integrations/on_error_integration.dart index 66fdc3e184..c075c7e724 100644 --- a/packages/flutter/lib/src/integrations/on_error_integration.dart +++ b/packages/flutter/lib/src/integrations/on_error_integration.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:sentry/sentry.dart'; // ignore: implementation_imports import 'package:sentry/src/utils/stacktrace_utils.dart'; @@ -83,8 +85,7 @@ class OnErrorIntegration implements Integration { stackTrace = getCurrentStackTrace(); hint = Hint.withMap({TypeCheckHint.currentStackTrace: true}); } - // unawaited future - hub.captureEvent(event, stackTrace: stackTrace, hint: hint); + unawaited(hub.captureEvent(event, stackTrace: stackTrace, hint: hint)); return handled; }; diff --git a/packages/flutter/test/integrations/flutter_error_integration_test.dart b/packages/flutter/test/integrations/flutter_error_integration_test.dart index a4ee7c8e9c..2f0b951059 100644 --- a/packages/flutter/test/integrations/flutter_error_integration_test.dart +++ b/packages/flutter/test/integrations/flutter_error_integration_test.dart @@ -41,8 +41,7 @@ void main() { _mockValues(); // replace default error otherwise it fails on testing - FlutterError.onError = - handler ?? (FlutterErrorDetails errorDetails) async {}; + FlutterError.onError = handler ?? (FlutterErrorDetails errorDetails) {}; final sut = fixture.getSut(); sut(fixture.hub, fixture.options); @@ -169,7 +168,7 @@ void main() { _mockValues(); var numberOfDefaultCalls = 0; - final defaultError = (FlutterErrorDetails errorDetails) async { + final defaultError = (FlutterErrorDetails errorDetails) { numberOfDefaultCalls++; }; FlutterError.onError = defaultError;