expo / sentry-expo

MIT License
202 stars 83 forks source link

fix(rn-options): Create new options object on every init to avoid read only error when initializing multiple times #350

Closed krystofwoldrich closed 1 year ago

krystofwoldrich commented 1 year ago

Checklist

Why

How

Because of the use of const DEFAULT_OPTIONS the options key _metadata was shared between multiple instances of Sentry when initialized twice in the same runtime, since Sentry saves default values to the _metadata and later on makes the options read-only the assign would fail the second time.

Test Plan

Sentry.init({...});

Sentry.init({...});

I've simulated the error by running the init multiple times, tho this should not ever be done in a real App. But it happens during the JS reload when the environment stays for example during OTA updates.