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

feat(core): Extract errors from props in unkown inputs #11526

Merged
merged 2 commits into from
Apr 12, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Apr 10, 2024

This changes the handling of unknown inputs for e.g. captureException(), to check if there is a property that holds an Error and use this.

So e.g. this:

const error = new Error('Some error');
Sentry.captureException({ message: 'something happened!', err: error });

Will use Some error as the error message, and also take the stacktrace from the error instead of the syntethic one.

There is of course the chance that this leads to false positives, if something is captured and contains a reference to an unrelated error instance. But I'd say this is not so likely, and we still keep the serialised object as extra on the event.

Should fix e.g. https://peated.sentry.io/issues/5166150355/?project=4505138086019073

@mydea mydea requested review from lforst, Lms24 and AbhiPrasad April 10, 2024 09:53
@mydea mydea self-assigned this Apr 10, 2024
Copy link
Contributor

github-actions bot commented Apr 10, 2024

size-limit report 📦

Path Size
@sentry/browser 22.17 KB (+0.2% 🔺)
@sentry/browser (incl. Tracing) 31.75 KB (+0.16% 🔺)
@sentry/browser (incl. Tracing, Replay) 67.07 KB (+0.08% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 60.47 KB (+0.07% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 70.91 KB (+0.07% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 80.8 KB (+0.07% 🔺)
@sentry/browser (incl. Feedback) 35.73 KB (+0.12% 🔺)
@sentry/browser (incl. Feedback, Feedback Modal) 35.73 KB (+0.11% 🔺)
@sentry/browser (incl. Feedback, Feedback Modal, Feedback Screenshot) 37.75 KB (+0.1% 🔺)
@sentry/browser (incl. sendFeedback) 26.97 KB (+0.15% 🔺)
@sentry/react 24.85 KB (+0.17% 🔺)
@sentry/react (incl. Tracing) 34.65 KB (+0.15% 🔺)
@sentry/vue 25.74 KB (+0.25% 🔺)
@sentry/vue (incl. Tracing) 33.46 KB (+0.15% 🔺)
@sentry/svelte 22.3 KB (+0.21% 🔺)
CDN Bundle 24.3 KB (+0.17% 🔺)
CDN Bundle (incl. Tracing) 32.78 KB (+0.12% 🔺)
CDN Bundle (incl. Tracing, Replay) 66.42 KB (+0.05% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 82.6 KB (+0.05% 🔺)
CDN Bundle - uncompressed 72.4 KB (+0.26% 🔺)
CDN Bundle (incl. Tracing) - uncompressed 98.38 KB (+0.19% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 208.04 KB (+0.09% 🔺)
@sentry/nextjs (client) 34.01 KB (+0.12% 🔺)
@sentry/sveltekit (client) 32.25 KB (+0.12% 🔺)
@sentry/node 120.33 KB (+0.12% 🔺)

@mydea mydea force-pushed the fn/better-unknown-error-extraction branch from e6af5d6 to ccd37bf Compare April 12, 2024 08:03
@mydea mydea enabled auto-merge (squash) April 12, 2024 08:03
@mydea mydea merged commit 35e464d into develop Apr 12, 2024
95 checks passed
@mydea mydea deleted the fn/better-unknown-error-extraction branch April 12, 2024 08:14
cadesalaberry pushed a commit to cadesalaberry/sentry-javascript that referenced this pull request Apr 19, 2024
This changes the handling of unknown inputs for e.g.
`captureException()`, to check if there is a property that holds an
`Error` and use this.

So e.g. this:

```js
const error = new Error('Some error');
Sentry.captureException({ message: 'something happened!', err: error });
```

Will use `Some error` as the error message, and also take the stacktrace
from the error instead of the syntethic one.

There is of course the chance that this leads to false positives, if
something is captured and contains a reference to an unrelated error
instance. But I'd say this is not so likely, and we still keep the
serialised object as `extra` on the event.

Should fix e.g.
https://peated.sentry.io/issues/5166150355/?project=4505138086019073
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants