Skip to content

Exception capture context is overwritten by native scope sync #2146

@lucas-zimerman

Description

@lucas-zimerman

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)
Which SDK and version?
e.g: Sentry React Native 3.3.3

Steps to Reproduce

Sample code:

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import * as Sentry from '@sentry/react-native';
Sentry.init({
  dsn:   'https://d870ad989e7046a8b9715a57f59b23b5@o447951.ingest.sentry.io/5428561',
  debug: true,
});

Sentry.captureException(new Error(`${Date.now()}: a test error occurred`),
context => context.addBreadcrumb({ message: 'error with breadcrumbs' }));

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Expected Result

The exception captured with the breadcrumb error with breadcrumbs

Actual Result

Breadcrumb got removed
https://sentry.io/organizations/sentry-sdks/issues/3114951206/?project=5428561&query=is%3Aunresolved&statsPeriod=1h

if (event.exception?.values?.[0]?.mechanism?.handled) {
event.breadcrumbs = [];
}

This code doesnt differentiate from synced breadcrumbs and local breadcrumbs, resulting on local breadcrumbs getting removed when setting an isolated scope/context.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions