Skip to content

Commit 8d9a47a

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/improve_on_error
2 parents 5e52b92 + db3cde2 commit 8d9a47a

File tree

9 files changed

+100
-13
lines changed

9 files changed

+100
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Unreleased
22

3+
# 6.0.0-beta.3
4+
5+
* Fix: Re-initialization of Flutter SDK (#526)
36
* Enhancement: Call `toString()` on all non-serializable fields (#528)
47
* Fix: Always call `Flutter.onError` in order to not swallow messages (#533)
58
* Bump: Android SDK to 5.1.0-beta.6 (#535)

dart/lib/src/isolate_error_integration.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@ import 'sentry_options.dart';
1010
import 'throwable_mechanism.dart';
1111

1212
class IsolateErrorIntegration extends Integration {
13-
late RawReceivePort _receivePort;
13+
RawReceivePort? _receivePort;
1414

1515
@override
1616
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);
2119
options.sdk.addIntegration('isolateErrorIntegration');
2220
}
2321

2422
@override
2523
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+
}
2829
}
2930
}
3031

dart/lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
library version;
1010

1111
/// The SDK version reported to Sentry.io in the submitted events.
12-
const String sdkVersion = '6.0.0-beta.3';
12+
const String sdkVersion = '6.0.0-beta.4';
1313

1414
String sdkName(bool isWeb) => isWeb ? _browserSdkName : _ioSdkName;
1515

dart/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sentry
2-
version: 6.0.0-beta.3
2+
version: 6.0.0-beta.4
33
description: >
44
A crash reporting library for Dart that sends crash reports to Sentry.io.
55
This library supports Dart VM and Web. For Flutter consider sentry_flutter instead.

dart/test/initialization_test.dart

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}

flutter/lib/src/default_integrations.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class NativeSdkIntegration extends Integration<SentryFlutterOptions> {
225225
NativeSdkIntegration(this._channel);
226226

227227
final MethodChannel _channel;
228-
late SentryFlutterOptions _options;
228+
SentryFlutterOptions? _options;
229229

230230
@override
231231
FutureOr<void> call(Hub hub, SentryFlutterOptions options) async {
@@ -272,7 +272,7 @@ class NativeSdkIntegration extends Integration<SentryFlutterOptions> {
272272
try {
273273
await _channel.invokeMethod<void>('closeNativeSdk');
274274
} catch (exception, stackTrace) {
275-
_options.logger(
275+
_options?.logger(
276276
SentryLevel.fatal,
277277
'nativeSdkIntegration failed to be closed',
278278
exception: exception,

flutter/lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// The SDK version reported to Sentry.io in the submitted events.
2-
const String sdkVersion = '6.0.0-beta.3';
2+
const String sdkVersion = '6.0.0-beta.4';
33

44
/// The default SDK name reported to Sentry.io in the submitted events.
55
const String sdkName = 'sentry.dart.flutter';

flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sentry_flutter
2-
version: 6.0.0-beta.3
2+
version: 6.0.0-beta.4
33
description: Sentry SDK for Flutter. This package aims to support different Flutter targets by relying on the many platforms supported by Sentry with native SDKs.
44
homepage: https://docs.sentry.io/platforms/flutter/
55
repository: https://github.com/getsentry/sentry-dart
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
}

0 commit comments

Comments
 (0)