File tree Expand file tree Collapse file tree 5 files changed +94
-9
lines changed Expand file tree Collapse file tree 5 files changed +94
-9
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
2
3
+ * Fix: Re-initialization of Flutter SDK (#526 )
3
4
* Enhancement: Call ` toString() ` on all non-serializable fields (#528 )
4
5
* Fix: Always call ` Flutter.onError ` in order to not swallow messages (#533 )
5
6
* Bump: Android SDK to 5.1.0-beta.6 (#535 )
Original file line number Diff line number Diff line change @@ -10,21 +10,22 @@ import 'sentry_options.dart';
10
10
import 'throwable_mechanism.dart' ;
11
11
12
12
class IsolateErrorIntegration extends Integration {
13
- late RawReceivePort _receivePort;
13
+ RawReceivePort ? _receivePort;
14
14
15
15
@override
16
16
FutureOr <void > call (Hub hub, SentryOptions options) async {
17
- _receivePort = _createPort (hub, options);
18
-
19
- Isolate .current.addErrorListener (_receivePort.sendPort);
20
-
17
+ final safeReceivePort = _receivePort = _createPort (hub, options);
18
+ Isolate .current.addErrorListener (safeReceivePort.sendPort);
21
19
options.sdk.addIntegration ('isolateErrorIntegration' );
22
20
}
23
21
24
22
@override
25
23
void close () {
26
- _receivePort.close ();
27
- Isolate .current.removeErrorListener (_receivePort.sendPort);
24
+ if (_receivePort != null ) {
25
+ final safeReceivePort = _receivePort! ;
26
+ safeReceivePort.close ();
27
+ Isolate .current.removeErrorListener (safeReceivePort.sendPort);
28
+ }
28
29
}
29
30
}
30
31
Original file line number Diff line number Diff line change
1
+ @TestOn ('vm' )
2
+
3
+ import 'package:sentry/sentry.dart' ;
4
+ import 'package:test/test.dart' ;
5
+
6
+ import 'mocks.dart' ;
7
+
8
+ // Tests for the following issue
9
+ // https://github.com/getsentry/sentry-dart/issues/508
10
+ // There are no asserts, test are succesfull if no exceptions are thrown.
11
+ void main () {
12
+ tearDown (() async {
13
+ await Sentry .close ();
14
+ });
15
+
16
+ test ('async re-initilization' , () async {
17
+ await Sentry .init ((options) {
18
+ options.dsn = fakeDsn;
19
+ });
20
+
21
+ await Sentry .close ();
22
+
23
+ await Sentry .init ((options) {
24
+ options.dsn = fakeDsn;
25
+ });
26
+ });
27
+
28
+ // This is the failure from
29
+ // https://github.com/getsentry/sentry-dart/issues/508
30
+ test ('re-initilization' , () {
31
+ Sentry .init ((options) {
32
+ options.dsn = fakeDsn;
33
+ });
34
+
35
+ Sentry .close ();
36
+
37
+ Sentry .init ((options) {
38
+ options.dsn = fakeDsn;
39
+ });
40
+ });
41
+ }
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ class NativeSdkIntegration extends Integration<SentryFlutterOptions> {
196
196
NativeSdkIntegration (this ._channel);
197
197
198
198
final MethodChannel _channel;
199
- late SentryFlutterOptions _options;
199
+ SentryFlutterOptions ? _options;
200
200
201
201
@override
202
202
FutureOr <void > call (Hub hub, SentryFlutterOptions options) async {
@@ -243,7 +243,7 @@ class NativeSdkIntegration extends Integration<SentryFlutterOptions> {
243
243
try {
244
244
await _channel.invokeMethod <void >('closeNativeSdk' );
245
245
} catch (exception, stackTrace) {
246
- _options.logger (
246
+ _options? .logger (
247
247
SentryLevel .fatal,
248
248
'nativeSdkIntegration failed to be closed' ,
249
249
exception: exception,
Original file line number Diff line number Diff line change
1
+ @TestOn ('vm' )
2
+
3
+ import 'package:flutter_test/flutter_test.dart' ;
4
+ import 'package:sentry/sentry.dart' ;
5
+ import 'package:sentry_flutter/sentry_flutter.dart' ;
6
+
7
+ import 'mocks.dart' ;
8
+
9
+ // Tests for the following issue
10
+ // https://github.com/getsentry/sentry-dart/issues/508
11
+ // There are no asserts, test are succesfull if no exceptions are thrown.
12
+ void main () {
13
+ tearDown (() async {
14
+ await Sentry .close ();
15
+ });
16
+
17
+ test ('async re-initilization' , () async {
18
+ await SentryFlutter .init ((options) {
19
+ options.dsn = fakeDsn;
20
+ });
21
+
22
+ await Sentry .close ();
23
+
24
+ await SentryFlutter .init ((options) {
25
+ options.dsn = fakeDsn;
26
+ });
27
+ });
28
+
29
+ // This is the failure from
30
+ // https://github.com/getsentry/sentry-dart/issues/508
31
+ test ('re-initilization' , () {
32
+ SentryFlutter .init ((options) {
33
+ options.dsn = fakeDsn;
34
+ });
35
+
36
+ Sentry .close ();
37
+
38
+ SentryFlutter .init ((options) {
39
+ options.dsn = fakeDsn;
40
+ });
41
+ });
42
+ }
You can’t perform that action at this time.
0 commit comments