getsentry / getsentry/sentry-dart

Calling Sentry capture methods within a new Isolate does not work

Open
#1,564 19 comments 1 reaction 0 assignees View on GitHub
Dart Errors Feature
Dominant language
Dart
Stars
873
Forks
299
Avg merge
2d 7h
Merged PRs (30d)
30

Description

### Description

Works fine:

```
throwingClosure(String message) async {
throw StateError(message);
}

final isolate = await Isolate.spawn(throwingClosure, "message", paused: true);
isolate.addSentryErrorListener();
isolate.resume(isolate.pauseCapability!);
```

Does not work:

```
throwingClosure(String message) async {
Sentry.captureException(message);
}

final isolate = await Isolate.spawn(throwingClosure, "message", paused: true);
isolate.addSentryErrorListener();
isolate.resume(isolate.pauseCapability!);
```

In this case, when you call any capture method, the `Hub` is `NoOpHub`, it's like the SDK isn't initialized within a different isolate, most likely because isolates are isolated :D and don't share any memory.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.