Skip to content

Commit c26ed0a

Browse files
authored
enh: remove async from FlutterErrorIntegration (#3202)
* Remove async from flutter error integration * Update * Update CHANGELOG
1 parent 68e9ac1 commit c26ed0a

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Use FFI/JNI for `captureEnvelope` on iOS and Android ([#3115](https://github.com/getsentry/sentry-dart/pull/3115))
2020
- Log a warning when dropping envelope items ([#3165](https://github.com/getsentry/sentry-dart/pull/3165))
2121
- Call options.log for structured logs ([#3187](https://github.com/getsentry/sentry-dart/pull/3187))
22+
- Remove async usage from `FlutterErrorIntegration` ([#3202](https://github.com/getsentry/sentry-dart/pull/3202))
2223
- Tag all spans during app start with start type info ([#3190](https://github.com/getsentry/sentry-dart/pull/3190))
2324

2425
### Dependencies

packages/flutter/lib/src/integrations/flutter_error_integration.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:async';
2+
13
import 'package:flutter/foundation.dart';
24
import 'package:sentry/sentry.dart';
35
import '../sentry_flutter_options.dart';
@@ -22,7 +24,7 @@ class FlutterErrorIntegration implements Integration<SentryFlutterOptions> {
2224
@override
2325
void call(Hub hub, SentryFlutterOptions options) {
2426
_defaultOnError = FlutterError.onError;
25-
_integrationOnError = (FlutterErrorDetails errorDetails) async {
27+
_integrationOnError = (FlutterErrorDetails errorDetails) {
2628
final exception = errorDetails.exception;
2729

2830
options.log(
@@ -88,7 +90,7 @@ class FlutterErrorIntegration implements Integration<SentryFlutterOptions> {
8890
stackTrace = getCurrentStackTrace();
8991
hint.addAll({TypeCheckHint.currentStackTrace: true});
9092
}
91-
await hub.captureEvent(event, stackTrace: stackTrace, hint: hint);
93+
unawaited(hub.captureEvent(event, stackTrace: stackTrace, hint: hint));
9294
// we don't call Zone.current.handleUncaughtError because we'd like
9395
// to set a specific mechanism for FlutterError.onError.
9496
} else {

packages/flutter/lib/src/integrations/on_error_integration.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:async';
2+
13
import 'package:sentry/sentry.dart';
24
// ignore: implementation_imports
35
import 'package:sentry/src/utils/stacktrace_utils.dart';
@@ -83,8 +85,7 @@ class OnErrorIntegration implements Integration<SentryFlutterOptions> {
8385
stackTrace = getCurrentStackTrace();
8486
hint = Hint.withMap({TypeCheckHint.currentStackTrace: true});
8587
}
86-
// unawaited future
87-
hub.captureEvent(event, stackTrace: stackTrace, hint: hint);
88+
unawaited(hub.captureEvent(event, stackTrace: stackTrace, hint: hint));
8889

8990
return handled;
9091
};

packages/flutter/test/integrations/flutter_error_integration_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ void main() {
4141
_mockValues();
4242

4343
// replace default error otherwise it fails on testing
44-
FlutterError.onError =
45-
handler ?? (FlutterErrorDetails errorDetails) async {};
44+
FlutterError.onError = handler ?? (FlutterErrorDetails errorDetails) {};
4645

4746
final sut = fixture.getSut();
4847
sut(fixture.hub, fixture.options);
@@ -169,7 +168,7 @@ void main() {
169168
_mockValues();
170169

171170
var numberOfDefaultCalls = 0;
172-
final defaultError = (FlutterErrorDetails errorDetails) async {
171+
final defaultError = (FlutterErrorDetails errorDetails) {
173172
numberOfDefaultCalls++;
174173
};
175174
FlutterError.onError = defaultError;

0 commit comments

Comments
 (0)