sentry-react-native
sentry-react-native copied to clipboard
Fix: don't symbolicate console asserts that comes from metro.
:loudspeaker: Type of change
- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
:scroll: Description
Adds a small patch to DebugSymbolicator that ignores events generated by metro.
:bulb: Motivation and Context
In short: when interacting with the metro bridge, React Native uses the following code: https://gitlab.cin.ufpe.br/vrs2/iot-trafficlight-final/-/blob/main/node_modules/event-target-shim/dist/event-target-shim.mjs?ref_type=heads#L40
/**
* Get private data.
* @param {Event} event The event object to get private data.
* @returns {PrivateData} The private data of the event.
* @private
*/
function pd(event) {
const retv = privateData.get(event);
console.assert(
retv != null,
"'this' is expected an Event object, but got",
event
);
return retv
}
When adding the Sentry console integration and also filtering by asserts, the above snippet can be called when we are symbolicating in dev builds, creating new events, that would then, be again symbolicated, and so on... By avoiding the symbolication of events that comes from this specific assert, apps when tested in debug mode should no longer freeze when loading the console integration.
Fixes: https://github.com/getsentry/sentry-react-native/issues/3992
Lastly. I marked it as no breaking changes since this only affect local builds
:green_heart: How did you test it?
Tests, locally, replicated the problematic library code so it is easier to test it on the sample app.
:pencil: Checklist
- [x] I added tests to verify changes
- [x] No new PII added or SDK only sends newly added PII if
sendDefaultPIIis enabled - [ ] I updated the docs if needed.
- [ ] I updated the wizard if needed.
- [ ] All tests passing
- [x] No breaking changes