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

Event: Non-Error promise rejection captured with keys: currentTarget, isTrusted, target, type #2546

Closed
1 of 5 tasks
susan-github opened this issue Apr 20, 2020 · 46 comments
Closed
1 of 5 tasks

Comments

@susan-github
Copy link

susan-github commented Apr 20, 2020

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?

@qtiki
Copy link

qtiki commented May 29, 2020

We've also started seeing these in the last couple of weeks. I just started looking into it so I don't have any more details on what's causing it.

@sheelah
Copy link

sheelah commented Jun 9, 2020

Same here, now on Sentry v5.15.5.

@kamilogorek
Copy link
Contributor

Can someone provide any link to this type of event captured in Sentry? It looks like a script loading error (notice the target that this event has been triggered on)

@Santas
Copy link

Santas commented Jun 12, 2020

@kamilogorek can you please send me your company email? I can share examples of the events.

@kamilogorek
Copy link
Contributor

@Santas kamil@sentry.io

@sheelah
Copy link

sheelah commented Jun 12, 2020

If you need more examples I can send some over as well @kamilogorek -- just let me know.

@kamilogorek
Copy link
Contributor

@sheelah yes, please

@kamilogorek
Copy link
Contributor

@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 onunhandledrejection event (same goes for onerror in 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") or Promise.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 see eventbuilder.ts file 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-L80

Unfortunately, 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)

@anton-bot
Copy link

anton-bot commented Jun 18, 2020

From my observations:

  • Only happens in various recent versions of Safari on mobile or desktop;
  • I have a few libraries installed in my web app such as ZXing and browser-image-compression, but no third-party tracking scripts;
  • It seems to occur at the exact same time as an API call fails with a Network Error (code 0).
  • In my case, it is more specifically a ProgressEvent, not just an event - which seems to be a part of HTTP request library (I am using axios).
ADDITIONAL DATA

__serialized__ | {
	currentTarget: [object Null],
	isTrusted: [Circular ~],
	target: [object FileReader],
	type: error}
-- | --

@amannn
Copy link

amannn commented Aug 12, 2020

I also just received a report with "Non-Error promise rejection captured with value: null". Similar to what @anton-bot mentioned above the affected user was using Safari 13.1.2 on Mac OS X 10.15.6.

I had a look in my compiled app code for reject( calls where a possibly null object is provided, but couldn't find any, so I was wondering if it might be a browser extension or 3rd party script. Since there's no stack trace or breadcrumbs it's quite hard to know what exactly happened.

@asbjornh
Copy link

asbjornh commented Aug 17, 2020

Have also been seeing this for the past two weeks. On our site we've only seen it on pages that use the google maps javascript API so I have a feeling that it might be related to that. Anyone else seeing this on URLs that use google maps?

Edit: So far we've seen the issue on iOS and Android

Edit: Additional data:

__serialized__
{
  currentTarget: [object Null], 
  isTrusted: [Circular ~], 
  target: head > script[type="text/javascript"], 
  type: error
}

@anton-bot
Copy link

@asbjornh nope I don't have Google Maps in my page

@asbjornh
Copy link

@kamilogorek Would OP's additional data (and mine) be caused by something like this Promise.reject(new Event("error"))? Or would Sentry events for this situation always have payloads that look like browser events?

@kamilogorek
Copy link
Contributor

@asbjornh yes, it'd then go through this flow -

if (isPlainObject(exception) || isEvent(exception)) {
// If it is plain Object or Event, serialize it manually and extract options
// This will allow us to group events based on top-level keys
// which is much better than creating new group when any key/value change
const objectException = exception as Record<string, unknown>;
event = eventFromPlainObject(objectException, syntheticException, options.rejection);
addExceptionMechanism(event, {
synthetic: true,
});
return event;
}

@avinashdvv
Copy link

I am also getting same error

@mcfarljw
Copy link

This error just depleted my quota capacity.

@JannikZed
Copy link

we have 289 events of this in the last 24h - and our page is not even live yet ..

{
currentTarget: [object Null], 
isTrusted: [Circular ~], 
target: head > link, 
type: error
}

We are using next.js

@krailler
Copy link

same here with cra 😅

@Turbo87
Copy link
Contributor

Turbo87 commented Oct 4, 2020

It seems that this issue is caused by something roughly like this:

new Promise((resolve, reject) => {
  const script = document.createElement('script');
  script.src = src;
  script.onload = resolve;
  script.onerror = reject;
  document.body.appendChild(script);
});

The onerror hook will actually receive an Event object, instead of an Error instance, which is causing these issues that are mentioned above. This can be avoided by wrapping the Event with an Error as suggested by https://developer.mozilla.org/de/docs/Web/API/HTMLScriptElement:

new Promise((resolve, reject) => {
  const script = document.createElement('script');
  script.src = src;
  script.onload = resolve;
  script.onerror = event => {
    reject(new Error(`Failed to load ${event.target.src}`));
  };
  document.body.appendChild(script);
});

@nickluger
Copy link

In my case it was Next.js' 9.5.2 prefetching mechanism causing it on Firefox, just in case somebody has a similar case. (maybe here? #2546 (comment)) This is the issue: vercel/next.js#16757 and can be solved by upgrading to 9.5.3 or Canary.

The error is much more verbose in the browser, though:

Uncaught (in promise) 
error
bubbles: false
...
...
as: "fetch"
assignedSlot: null
attributes: NamedNodeMap(3
0: href="/_next/data/wmQYPCwvbuBulJfEwTMRf/smartwatches/fitbit-ionic.json"
1: rel="prefetch"
2: as="fetch"
as: as="fetch"
href: href="/_next/data/wmQYPCwvbuBulJfEwTMRf/smartwatches/fitbit-ionic.json"
length: 3
rel: rel="prefetch"
...
...
​
isTrusted: true
originalTarget: <link href="/_next/data/wmQYPCwvbuBu…tches/fitbit-ionic.json" rel="prefetch" as="fetch">
returnValue: true
srcElement: <link href="/_next/data/wmQYPCwvbuBu…tches/fitbit-ionic.json" rel="prefetch" as="fetch">​
target: <link href="/_next/data/wmQYPCwvbuBu…tches/fitbit-ionic.json" rel="prefetch" as="fetch">
timeStmp: 25366
type: "error"
...

How can we get Sentry to capture this data?

@asbjornh
Copy link

asbjornh commented Oct 5, 2020

@Turbo87 YES! This is exactly why we're only seeing it on pages using @googlemaps/js-api-loader. They're doing exactly what you're describing here

Thank you!!

@bdowling-chwy
Copy link

Very useful @Turbo87! I couldn't find a comparable property for link elements. Is there one, in case the href is invalid?

@lobsterkatie
Copy link
Member

BTW - the isTrusted: [Circular ~] value (incorrect, since it's a boolean) is fixed here: #3864.

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@huangjihua
Copy link

image

  • [ React] ^17.0.1
  • [ axios]^0.21.1
  • [sentry/react] ^6.18.0

I encountered the same problem。

@lobsterkatie
Copy link
Member

@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.

@karmeljuk
Copy link

Hello everyone
I have the same issue, you can check sharable link here https://sentry.io/share/issue/213a44af1eac4f7e85ea5714bc3f7f1e/

Unhandled
Non-Error promise rejection captured with keys: currentTarget, detail, isTrusted, target

currentTarget: [object Window], 
detail: None, 
isTrusted: False, 
target: [object Window], 
type: unhandledrejection
}

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:
image

Any ideas how it's possible to fix this issue?

@aviadavi
Copy link

latest react SDK 7.27.0 still getting many of those

@andirsun
Copy link

Same error on React 18 + Next 13

@sach999
Copy link

sach999 commented Jan 23, 2023

We still seem to be getting this error

@gocarlos
Copy link

It seems that this should not be closed... we are running angular with latest sentry-ivy and also getting those errors on safari

@futzlarson
Copy link

I would agree. The documentation update is nice, but I still have no idea what is causing this as I am not doing any of these:

  • call Sentry.captureException() with a plain object
  • throw a plain object
  • reject a promise with a plain object

__serialized__ shows:

{
    currentTarget: [object Null], 
    isTrusted: True, 
    target: [object Window], 
    type: error
}

Which also isn't helpful. This is only happening in Safari, so I wonder if it's that or a browser extension, as was the case for the very similar error Non-Error promise rejection captured with value. Should I just add Non-Error exception captured with keys to ignoreErrors or is that more broad than it needs to be?

@harryfear
Copy link

harryfear commented Apr 25, 2023

Having the same issue as @futzlarson.

For us, it's happening almost-exclusively (97%) on iPhone.

image

This is a bind, as it's hard to know what's going on, as nothing obviously relevant in our codebase has changed since we started getting these issue(s) 12 days ago.

@dgbeck
Copy link

dgbeck commented Apr 28, 2023

we also started seeing these errors recently (like, two weeks ago)

@futzlarson
Copy link

I emailed them. Their recommendation was to filter out this specific error, which I plan on doing with ignoreErrors. Seems they are considering doing this at the Sentry level.

@harryfear
Copy link

Still getting this in production, including just 4h ago. And others are, too.

I really hope Sentry implements a global suppression for this.

@felix-berlin
Copy link

We are also receiving this error:

image

image

Does anyone have any new insight on how to track down this error or ignore it?

@ohansFavour
Copy link

@felix-berlin to ignore this error, add it to ignoreErrors list

  ignoreErrors: [
    'Non-Error exception captured',
    'Non-Error promise rejection captured'
  ]

Ref: https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-platformidentifier-nameignore-errors-

@victorlmneves
Copy link

doing this at the Sentry level

I'm doing that and I still get those errors reported on Sentry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests