sentry-javascript: Event: Non-Error promise rejection captured with keys: currentTarget, isTrusted, target, type
Package + Version
-
@sentry/browser -
@sentry/node -
raven-js -
raven-node(raven for node) - other:
Version:
5.10.2
Description
My project often catch an error like Event Non-Error promise rejection captured with keys: currentTarget, isTrusted, target, type,without any useful information. And an additional data is
__serialized__ = {
currentTarget: [object Null],
isTrusted: [Circular ~],
target: head > script[type="text/javascript"],
type: error
}
looks like an Event instance. With the limited information,I don’t know where this bug is triggered,has anyone encountered the same problem?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 79
- Comments: 46 (10 by maintainers)
Commits related to this issue
- More useful Error in import onerror See https://github.com/getsentry/sentry-javascript/issues/2546#issuecomment-703331367 — committed to TjeuKayim/aleph.js by TjeuKayim 3 years ago
- More useful Error in import onerror See https://github.com/getsentry/sentry-javascript/issues/2546#issuecomment-703331367 — committed to TjeuKayim/aleph.js by TjeuKayim 3 years ago
- More useful Error in import onerror (#403) See https://github.com/getsentry/sentry-javascript/issues/2546#issuecomment-703331367 — committed to alephjs/aleph.js by TjeuKayim 3 years ago
It seems that this issue is caused by something roughly like this:
The
onerrorhook will actually receive anEventobject, instead of anErrorinstance, which is causing these issues that are mentioned above. This can be avoided by wrapping theEventwith anErroras suggested by https://developer.mozilla.org/de/docs/Web/API/HTMLScriptElement:This error just depleted my quota capacity.
@sheelah there’s not much we can improve here, to be honest. JS doesn’t give us more information that we already provide. Whenever an instance of a promise object is rejected, it triggers
onunhandledrejectionevent (same goes foronerrorin the OP description).https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event
However, there’s nothing that would stop anyone from passing any random stuff in there. Thus code like this
Promise.reject("whatever")orPromise.reject(jQueryBecauseWhyNot)is totally valid JS code.Whenever we encounter something that’s not a primitive value, an object that contains the stack trace (eg.
Error) or internal DOM exception, we have to fall back to simple object serialization and try to extract whatever information we can out of it. You can seeeventbuilder.tsfile for a list of possible paths this “any random value” passed to the event handler can take – https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/eventbuilder.ts#L17-L80Unfortunately, I’m not sure if we can make it any more generic to handle more types of input. If anyone has any feedback regarding that process, I’m totally open to suggestions.
(answered here instead of to your email, to keep the conversation public for everyone else)
My impression is that most of these errors are a side effect of your visitors using adblockers.
From my observations:
ZXingandbrowser-image-compression, but no third-party tracking scripts;ProgressEvent, not just an event - which seems to be a part of HTTP request library (I am using axios).In my case it was Next.js’
9.5.2prefetching mechanism causing it on Firefox, just in case somebody has a similar case. (maybe here? https://github.com/getsentry/sentry-javascript/issues/2546#issuecomment-697771381) This is the issue: https://github.com/vercel/next.js/pull/16757 and can be solved by upgrading to9.5.3or Canary.The error is much more verbose in the browser, though:
How can we get Sentry to capture this data?
we have 289 events of this in the last 24h - and our page is not even live yet …
We are using next.js
@felix-berlin to ignore this error, add it to ignoreErrors list
Ref: https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-platformidentifier-nameignore-errors-
Still getting this in production, including just 4h ago. And others are, too.
I really hope Sentry implements a global suppression for this.
We still seem to be getting this error
Hello everyone I have the same issue, you can check sharable link here https://sentry.io/share/issue/213a44af1eac4f7e85ea5714bc3f7f1e/
The site is on WordPress with 40 plugins (WPML, YOAST, WooCommerce etc) and we have HubSpot forms integrated into WP pages. As i see in the DevTools it’s can be HubSpot form js file only https://js.hsforms.net/forms/v2.js:
Any ideas how it’s possible to fix this issue?
@huangjihua - At this point, as far as we know, all of the bugs have been worked out here. Docs about this are now here: https://docs.sentry.io/platforms/javascript/troubleshooting/#events-with-non-error-exception.
same here with cra 😅
@asbjornh yes, it’d then go through this flow - https://github.com/getsentry/sentry-javascript/blob/caff9e7b308f99f04443d57d990c252a51a153bf/packages/browser/src/eventbuilder.ts#L97-L107
@asbjornh nope I don’t have Google Maps in my page
@sheelah yes, please