-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/react
SDK Version
7.13.0
Framework Version
react 17.0.2
Link to Sentry event
No response
Steps to Reproduce
I have a react component where I observe a valid error because we access a prop of an undefined object. My concern is I am not seeing the error appear in Sentry, and while investigating, it seems that https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/helpers.ts#L117 exception is thrown and never sent to sentry and I can't understand why.
example react code where the error happens
state of my component which causes the error:
Categories = {};
myObject = {rule: {Category: 'MyCategory'}};
<strong
{Categories[myObject.rule.Category].title}
</strong>
When the error is thrown, it is being caught from within browser/src/helpers
TypeError: Cannot read properties of undefined (reading 'title')
Expected Result
line 117 of the helper throws the exception, I expect that it would be sent to sentry but it never appears.
I have set up a beforeSend within Sentry.init
to verify all sent requests, and this case it is never called.
Sentry.init({
dsn: "...",
environment: "...",
release: "...",
beforeSend: (event, hint) => {
console.log({ event, hint });
// for debugging I want to see what goes to sentry
return null;
},
});
### Actual Result
thrown exception from react is never sent to Sentry.
I'm not sure how to create a reproduction without a public sentry instance.