From 4682741a66e9bc172d0f741ed3c9ffc8a10f1ca9 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Wed, 27 Aug 2025 12:23:58 +0200 Subject: [PATCH 1/3] Remove async from flutter error integration --- .../lib/src/integrations/flutter_error_integration.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/integrations/flutter_error_integration.dart b/packages/flutter/lib/src/integrations/flutter_error_integration.dart index 4e5965c561..5d87891a69 100644 --- a/packages/flutter/lib/src/integrations/flutter_error_integration.dart +++ b/packages/flutter/lib/src/integrations/flutter_error_integration.dart @@ -22,7 +22,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 +88,7 @@ class FlutterErrorIntegration implements Integration { stackTrace = getCurrentStackTrace(); hint.addAll({TypeCheckHint.currentStackTrace: true}); } - await hub.captureEvent(event, stackTrace: stackTrace, hint: hint); + 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 { From 870fee42fa5e650daa28df3bc014795f26bccebc Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Wed, 27 Aug 2025 12:34:34 +0200 Subject: [PATCH 2/3] Update --- .../lib/src/integrations/flutter_error_integration.dart | 4 +++- .../flutter/lib/src/integrations/on_error_integration.dart | 5 +++-- .../test/integrations/flutter_error_integration_test.dart | 5 ++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/flutter/lib/src/integrations/flutter_error_integration.dart b/packages/flutter/lib/src/integrations/flutter_error_integration.dart index 5d87891a69..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'; @@ -88,7 +90,7 @@ class FlutterErrorIntegration implements Integration { stackTrace = getCurrentStackTrace(); hint.addAll({TypeCheckHint.currentStackTrace: true}); } - 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; From ef0cf63df993338253b5c711c6d62320490ea475 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Thu, 28 Aug 2025 11:30:01 +0200 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4383846760..86a7ab3b8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Bumped `dio` min verion to `5.2.0` - 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)) ### Dependencies