sentry-javascript: Error message property logged as [object ErrorEvent]

Do you want to request a feature or report a bug? Bug.

What is the current behavior? Sometimes (not always) the message property of the error is logged as [object ErrorEvent]. I followed the standard implementation of Raven in Angular as described here: https://docs.sentry.io/clients/javascript/integrations/angular/.

What is the expected behavior? To see a normal error message.

Raven 3.17.0 Angular 4.3.1 Webpack build Not using CLI CDN version

objecterrorevent

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 10
  • Comments: 31 (17 by maintainers)

Most upvoted comments

Hi, I am getting a lot of these errors [object Object]. screenshot 2017-12-01 09 41 20

Angular 4 Chrome 62.0.3202 Raven-js 3.20.1

I found the issue. ErrorEvent is not being treated as an error by the isError util function, which can be found here. For convenience, I’ll paste the function definition also:

function isError(value) {
  switch ({}.toString.call(value)) {
    case '[object Error]':
      return true;
    case '[object Exception]':
      return true;
    case '[object DOMException]':
      return true;
    default:
      return value instanceof Error;
  }
}

I did a quick test in my console to see whether or not this function would return true for an ErrorEvent, and it did not:

image

isError is used in the captureException method to determine whether the exception parameter is an error or simply a message. captureException will send exceptions to the dashboard using captureMessage if it thinks the exception is not actually an error. In this case, Raven will not compute a stack trace or “process” the exception. It just sends it off as is.

Is there any reason we shouldn’t update isError to return true for ErrorEvent objects?

<script>
  undefined.foo();
</script>

^ This in your html is logged in safari via sentry as [object ErrorEvent]. Correct message would have been TypeError: undefined is not an object (evaluating 'undefined.foo').

We have an external script that injects code via script tag that tries to create an iframe, but thats blocked by safari. As the error originates from the injected script tag, sentry just reports [object ErrorEvent]

It looks like traceKitWindowOnError doesn’t process correctly input parameters when ‘message’ parameter is an ErrorEvent object: screen shot 2017-11-06 at 11 36 34 and ‘ex’ is undefined. Then, it invokes notifyHandlers with an object where ‘message’ field is an ErrorEvent, not string: screen shot 2017-11-06 at 11 41 14 which, when strigified in _makeRequest, produces meaningless message.

I understand. I’ll put up a PR in a few minutes.

Sure, I believe this can be solved – I just meant that it is not as simple as just augmenting isError to return true.

Another error from sentry reported as just [object Event] is from the flowplayer. The flowplayer does

jQueryElement.trigger('error', [api, {code: 5}]);

You can reproduce it by embedding jQuery and just do:

$('div:first').trigger('error')

Sentry sees something like this image

Sure thats not very serializable, but an error like error on element from jQuery - context <div class="foo><div class="bar" ... would be much more helpful then [object Event]