question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:66
  • Comments:36 (9 by maintainers)

github_iconTop GitHub Comments

30reactions
Turbo87commented, 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);
});
24reactions
mcfarljwcommented, Sep 10, 2020

This error just depleted my quota capacity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am I seeing events with "Non-Error exception (or ...
If you're seeing errors having the message "Non-Error exception (or promise rejection) captured with keys: x, y, z.
Read more >
Non-Error promise rejection captured with value
I'm getting tons of errors from from what appears to be a recursive call generating a lot of errors from one unhandled exception:...
Read more >
Event: Non-Error promise rejection captured with keys
My project often catch an error like Event Non-Error promise rejection captured with keys: currentTarget, isTrusted, target, type,without ...
Read more >
Non-Error promise rejection captured with value: undefined
Pass something in reject('something went wrong')) ;. It's empty ( undefined ) that's why you see that error.
Read more >
Window: unhandledrejection event - Web APIs | MDN
The unhandledrejection event is sent to the global scope of a script when a JavaScript Promise that has no rejection handler is rejected; ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found