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.

Very uninformative onunhandledrejection errors when rejecting with Event

See original GitHub issue

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.6.2

Description

Errors captured through onunhandledrejection mechanism never really provide any useful information that would help in figuring out the problem.

In my app, I have thousands (17K as of now for one of them, after few months) of UnhandledRejection errors. All info that those events provide is just a an error text like UnhandledRejection: "CustomEvent" (note that with latest version of Sentry it became a little bit more informative with UnhandledRejection: Non-Error promise rejection captured with keys: isTrusted text). There is no stack nor extra context and those errors happen on routes and paths that work perfectly for me and everyone I know so I’m unable figure out how to address them.

Now, I assume, that the problem is only with unhandled promise rejections that reject with non-Error type like primitive values (string, null, etc.) or (like in this case) an Event object. While I don’t see how to improve cases with primitive values, I think for event objects, more data could be logged.

It seems the UnhandledRejection: Non-Error promise rejection captured with keys: isTrusted message comes from the fact that isTrusted is the only iterable key on the event object (try console.log(Object.keys(new CustomEvent('test')))). But event objects have more useful (non-iterable) keys that could provide more information about the error. Namely I’m thinking about detail and type properties. I think those could help identifying from which code event is coming from.

So I’m suggesting to add some custom code (if there isn’t already) for handling that special case (unhandledrejection with event object) better.

Some example events: https://sentry.io/share/issue/4d294f75e9704103b7c3b49e62b6e278/ https://sentry.io/share/issue/c36904ab4c224fbda6f1afff63c106ee/ (these are minimal, sharable versions but full events don’t really provide any other meaningful information either.)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:69
  • Comments:74 (15 by maintainers)

github_iconTop GitHub Comments

16reactions
cynicaloptimistcommented, Aug 31, 2019

I’m currently receiving thousands of instances of this error from a relatively small number of users. Since I’m just testing out Sentry right now with a free plan, there’s no way to filter them out. Spike Protection also does not seem to react to this issue.

14reactions
kamilogorekcommented, Sep 10, 2019

I scheduled better Event/CustomEvent handling work for the next week. Will keep everyone posted on this one.

@mogelbrod is there a way you can provide a repro-case for this? We never had an issue with TraceKit incorrectly detecting Error instances.

As for your additional enumerables, we have an integration for this – https://docs.sentry.io/platforms/javascript/#extraerrordata

import * as Sentry from '@sentry/browser';
import { ExtraErrorData } from '@sentry/integrations';

Sentry.init({
  integrations: [new Integrations.ExtraErrorData()]
});

is basically equivalent of your beforeSend snippet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Why does onerror not intercept exceptions from promises and ...
I want to use onerror to intercept and log all errors that occur in my JavaScript application. This works as expected ...
Read more >
What is an onunhandledrejection in javascript? - Educative.io
The onunhandledrejection is an event handler to process ... These errors show that an unhandled promise rejection is thrown by the code and...
Read more >
Non-Error promise rejection captured with value - #sentry
I'm getting tons of errors from from what appears to be a recursive call ... the stack there is an “exception” and then...
Read more >
Window: unhandledrejection event - Web APIs
Basic error logging. This example simply logs information about the unhandled promise rejection to the console. window.addEventListener("unhandledrejection", ...
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