Skip to content

Commit 4e40541

Browse files
committed
Capture Future errors for Flutter Web automatically
1 parent 873fb42 commit 4e40541

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Capture Future errors for Flutter Web automatically ([#1143](https://github.com/getsentry/sentry-dart/pull/1143))
8+
39
## 6.16.1
410

511
### Fixes

flutter/lib/src/integrations/flutter_error_integration.dart

-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ class FlutterErrorIntegration extends Integration<SentryFlutterOptions> {
6060
final mechanism = Mechanism(
6161
type: 'FlutterError',
6262
handled: true,
63-
data: {
64-
if (flutterErrorDetails.isNotEmpty)
65-
'hint':
66-
'See "flutter_error_details" down below for more information'
67-
},
6863
);
6964
final throwableMechanism = ThrowableMechanism(mechanism, exception);
7065

flutter/lib/src/sentry_flutter.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ mixin SentryFlutter {
5252

5353
final platformDispatcher = PlatformDispatcher.instance;
5454
final wrapper = PlatformDispatcherWrapper(platformDispatcher);
55-
final isOnErrorSupported = wrapper.isOnErrorSupported(flutterOptions);
55+
56+
// Flutter Web don't capture [Future] errors if using [PlatformDispatcher.onError] and not
57+
// the [runZonedGuarded].
58+
// likely due to https://github.com/flutter/flutter/issues/100277
59+
final isOnErrorSupported = flutterOptions.platformChecker.isWeb
60+
? false
61+
: wrapper.isOnErrorSupported(flutterOptions);
5662

5763
// first step is to install the native integration and set default values,
5864
// so we are able to capture future errors.

flutter/test/integrations/flutter_error_integration_test.dart

-4
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ void main() {
5656
final throwableMechanism = event.throwableMechanism as ThrowableMechanism;
5757
expect(throwableMechanism.mechanism.type, 'FlutterError');
5858
expect(throwableMechanism.mechanism.handled, true);
59-
expect(throwableMechanism.mechanism.data['hint'],
60-
'See "flutter_error_details" down below for more information');
6159
expect(throwableMechanism.throwable, exception);
6260

6361
expect(event.contexts['flutter_error_details']['library'], 'sentry');
@@ -92,8 +90,6 @@ void main() {
9290
final throwableMechanism = event.throwableMechanism as ThrowableMechanism;
9391
expect(throwableMechanism.mechanism.type, 'FlutterError');
9492
expect(throwableMechanism.mechanism.handled, true);
95-
expect(throwableMechanism.mechanism.data['hint'],
96-
'See "flutter_error_details" down below for more information');
9793

9894
expect(event.contexts['flutter_error_details']['library'], 'sentry');
9995
expect(event.contexts['flutter_error_details']['context'],

0 commit comments

Comments
 (0)