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

fix(utils): Fix false-positive circular references when normalizing Event objects #3864

Merged
merged 4 commits into from
Aug 5, 2021

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Aug 4, 2021

When captureException is passed a non-Error object, we do our best to extract as much data as we can from that object. (That's what leads to the much-maligned "Non-Error exception [or promise rejection] captured with keys x, y, and z" error message.)

A common case in which this occurs is when code of the form Promise.reject(someEvent) runs - common enough, in fact, that we handle Event objects separately. Specifically, we capture the event's type, target (the element which caused the event), and currentTarget (the element with the event listener on it) properties (none of which are enumerable), along with anything else on the event which is enumerable. For most events, that "anything else" includes only one property: isTrusted, a boolean indicating whether or not the event is the result of a user action.

For a long time, though, isTrusted has been showing up not as a boolean but as [Circular ~]. It turns out that's because when we try to grab the enumerable property values, we end up grabbing the entire event instead. (It's only shown up in the isTrusted value, but only because that's the only enumerable property on most Events.) This fixes that, and adds a test for pulling data out of Event objects.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 21.57 KB (+0.03% 🔺)
@sentry/browser - Webpack 22.57 KB (+0.04% 🔺)
@sentry/react - Webpack 22.6 KB (+0.03% 🔺)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.99 KB (+0.02% 🔺)

packages/utils/test/testutils.ts Show resolved Hide resolved
@lobsterkatie lobsterkatie merged commit 5e2ddf3 into master Aug 5, 2021
@lobsterkatie lobsterkatie deleted the kmclb-fix-is-trusted-circular branch August 5, 2021 20:02
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.

None yet

2 participants