Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception withContext is overwritten by native scope sync #1658

Open
krystofwoldrich opened this issue Sep 27, 2023 · 1 comment
Open

Exception withContext is overwritten by native scope sync #1658

krystofwoldrich opened this issue Sep 27, 2023 · 1 comment

Comments

@krystofwoldrich
Copy link
Member

krystofwoldrich commented Sep 27, 2023

Description

Expected:

This code should capture the exception with extra breadcrumb.

    await Sentry.captureException(error, stackTrace: stackTrace, withScope: (scope) {
      scope.addBreadcrumb(Breadcrumb(message: 'breadcrumb from with scope'));
    });

Actual:

The breadcrumb is missing.

Culprit:

final breadcrumbsList = infos['breadcrumbs'] as List?;
if (breadcrumbsList != null &&
breadcrumbsList.isNotEmpty &&
_options.enableScopeSync) {
final breadcrumbsJson =
List<Map<dynamic, dynamic>>.from(breadcrumbsList);
final breadcrumbs = <Breadcrumb>[];
for (final breadcrumbJson in breadcrumbsJson) {
final breadcrumb = Breadcrumb.fromJson(
Map<String, dynamic>.from(breadcrumbJson),
);
breadcrumbs.add(breadcrumb);
}
event = event.copyWith(breadcrumbs: breadcrumbs);
}

Notes:
The local exception scope is overridden by the one we fetch from the native SDKs. Scope fetched from a native SDK contains both Flutter and Native data. We shouldn't introduce duplicates.

@krystofwoldrich
Copy link
Member Author

Related issue in RN getsentry/sentry-react-native#2146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

3 participants