Skip to content

Commit 67277fc

Browse files
authored
Test wether isolate completes when sentry is closed (#2822)
1 parent 3fcbad3 commit 67277fc

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

dart/test/sentry_test.dart

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:isolate';
23

34
import 'package:sentry/sentry.dart';
45
import 'package:sentry/src/dart_exception_type_identifier.dart';
@@ -412,7 +413,37 @@ void main() {
412413
);
413414
expect(options.debug, isFalse);
414415
});
415-
});
416+
417+
test('isolate completes when closing sentry', () async {
418+
final onExit = ReceivePort();
419+
420+
Future<void> _runSentry(String message) async {
421+
await Sentry.init((options) {
422+
options
423+
..dsn = fakeDsn
424+
..tracesSampleRate = 1.0;
425+
});
426+
await Sentry.close();
427+
}
428+
429+
final completer = Completer<void>();
430+
431+
await Isolate.spawn<String>(
432+
_runSentry,
433+
'test',
434+
onExit: onExit.sendPort,
435+
);
436+
437+
var completed = false;
438+
onExit.listen((message) {
439+
completed = true;
440+
completer.complete();
441+
});
442+
443+
await completer.future;
444+
expect(completed, true);
445+
});
446+
}, testOn: 'vm');
416447

417448
test('should complete when appRunner is not called in runZonedGuarded',
418449
() async {

0 commit comments

Comments
 (0)