Sentry-javascript: Old browsers cause [object Event] to be logged

Created on 3 Aug 2015  ·  50Comments  ·  Source: getsentry/sentry-javascript

Just as described in this thread on Stack Overflow, certain events sent to window.onerror will cause [object Event] to be logged as the message and not much else. It would be neat if Sentry could detect these ancient Event objects and dig out some details from them so what is logged to Sentry is something intelligible we can act upon and attempt to fix.

Most helpful comment

@rollokb – any news on this?

All 50 comments

One particular sample from our logs show the following information:

  • Browser: Dolfin 3.0
  • Device: Samsung GT-S8600
  • OS: Bada 2.0

I can verify that the Android browser from Android 4.1 through 4.4, seemingly from 3rd-party Android phones (e.g. Samsung, HTC) are similarly affected by this issue. I cannot confirm if Nexus phones are affected.

This would be a great feature to get, and it doesn't seem relatively difficult to implement. Perhaps a quick check if message.toString() == '[object Event]' and then a for-in loop to access properties of the event object. This would be great in helping debug issues with a site in Android 4.1 - 4.4.

@d10 – I've experimented with that, but I can't find a real browser to verify that it works. I've tried emulating Android 4.1 – 4.4 on BrowserStack and using the stock Android browser, but they report errors just fine.

That would be a great feature! We have the same problems with old browsers!

This was driving me crazy so I wrote a patch for this https://github.com/rollokb/raven-js/tree/feat/old-webkit-Event-handling

I'm going to test it out in production for a bit before submitting a pull request.

@rollokb – that commit looks great. Let me know how it goes in production; I'd be glad to merge it into master afterwards.

Great! It is driving me nuts as well! +1

Seems to be working fine in production.

Edit:

Seems to be working fine, but only with Events which I've trigged myself. Still getting absolutely no information about the contents of the Event.

Seems to be working fine, but only with Events which I've trigged myself. Still getting absolutely no information about the contents of the Event.

The problem is likely here:

+        for (var property in event) {
+            if (event.hasOwnProperty(property)) {
+                options.extra[property] = event[property];
+            }
+         }

By checking hasOwnProperty, you're not going to get any properties that derive from Event.prototype. Unless these affected browsers are doing as you do in your test – placing properties directly on the Event object they create – we won't see any data.

The flip side is, if you remove that check, we're going to get a bunch of properties that have nothing to do with the error. But it might be worth seeing that that looks like.

You're probably right. I was caught out by this when testing with PhantomJS.

Updated the branch
https://github.com/rollokb/raven-js/blob/feat/old-webkit-Event-handling/src/raven.js#L1109-L1121

Cool. Again, I appreciate you digging into this.

Slightly of-topic, but how is PhantomJS being loaded on this project? It seems to handle event properties incorrectly (i.e, it sees all Event props as its own).

Via kmiyashiro/grunt-mocha

https://github.com/getsentry/raven-js/blob/master/Gruntfile.js#L193

It seems to handle event properties incorrectly (i.e, it sees all Event props as its own).

You could try mocking an Event object that is behaves the same as is observed in Chrome/some other browser. (Hopefully the legacy browsers sending these objects feel similarly.)

You could also try getting the tests to run Phantom2 to see if the behavior is more accurate. I believe they run 1.9.8 right now.

@rollokb – any news on this?

I got hundreds of those today from Facebook Browser v80 on Android 4. That is not really old, is it?

We're getting many of these errors on Android 4.x with Android Browser

I got hundreds of those today from Facebook Browser v80 on Android 4. That is not really old, is it?

I'm pretty sure "Facebook Browser" is just Facebook wrapping whatever the internal web browser is.

Basically, this error only crops up in a bunch of international versions of Android phones. Take a look at your device list when you see such errors, you'll notice they have device codes like Samsung GT-S8600 – which are not North American/Western models.

They appear to be using some fork of a browser that purports to be "Chrome Mobile" or "Android Browser" (user agents are easily faked), but appears to have a different Error object signature. I've had a hard time reproducing the error (including trying to purchase some of these phones for use in the office), but I'll likely give it another go sometime soon.

We are not getting those errors on rare browsers, we just got it on Windows 10 with Chrome 51.0.2704

Hi, guys!

Also I've got the Raven report

...
"exception": {
  "values": [
    {
      "value": "[object Event]",
      "stacktrace": {
        "frames": [
          ...
        ]
      }
    }
  ]
}

in mobile browser on Android. The user agent is
Mozilla/5.0 (Linux; U; Android 4.4.2; de-de; GT-N7100 Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

+1 for this

So, as of 3.7.0, we now generate synthetic traces for [object Event] and other caught non-Error objects. I'd recommend trying 3.7.0 and seeing what results you get.

@benvinegar I have 3.7.0 installed, but getting this error

I'm using the next hack as temporary solution:

    Raven.install();

    if (Raven._processException) {
        const oldProcessException = Raven._processException;

        Raven._processException = function (event, message) {
            if (message && typeof message === 'object') {
                // detect that it's an event
                if (String(message) === '[object Event]') {
                    // message
                    message = stringifyEvent(message);

                    // type
                    event = event || 'event';
                } else {
                    // stringify the other objects
                    try {
                        message = JSON.stringify(message);
                    } catch (e) {
                        //
                    }
                }

                arguments[0] = event;
                arguments[1] = message;
            }

            return oldProcessException.apply(this, arguments);
        };
    }

    function stringifyEvent (event) {
        const data = {
            eventPhase: event.eventPhase,
            type: event.type,
            isTrusted: event.isTrusted,
            returnValue: event.returnValue,
            timeStamp: event.timeStamp
        };

        if (event.target) {
            data.target = {
                src: event.target.src,
                tagName: event.target.tagName || 'UNKNOWN_HTMLELEMENT',
                className: event.target.className,
                readyState: event.target.readyState
            };
        }

        if (event.path) {
            data.path = event.path.map((el) => {
                const tagName = el.tagName || 'UNKNOWN_HTMLELEMENT';
                const className = (el.className || '').replace(/\s+/, '');

                // DIV.class-1.class-2
                return `${ tagName }.${ className }`;
            });
        }

        return JSON.stringify(data);
     }

@webschik Looks like a typo in this line:

return `${ tagName }.${ className }`;

And are you sure about this construction is allowed:

data.path = event.path.map((el) => {

UP: Getting "Unexpected token =>" error with this fix

@webschik

2016-09-23 12 45 43

@AlexanderMatveev, it's ES2015 syntax.
You can replace it

@webschik Added this hack and looks like nothing changed, still getting just "[object Event]" error.

@AlexanderMatveev, it's weird, because this works for my project. Probably we need more investigations there

@webschik

Here is the scripts order:

<script type="text/javascript" src="[raven.min.js version 3.7.0]"></script>
<script>
    Raven.config('https://[...]@sentry.io/[...]', {
        release: '[...]'
    }).install();
</script>
<script type="text/javascript" src="[fix.js without first Raven.install() line]"></script>

@benvinegar I have 3.7.0 installed, but getting this error

You would still get it. The difference is that it should generate a synthetic stack trace. However, if it is caught because it bubbles up to window.onerror, the stack trace might not be helpful (but it would tell you that's how it's being caught).

Had the same with Raven 3.6.1 on hosted Sentry for UA: Mozilla/5.0 (Linux; U; Android 3.1; en-gb; GT-P7500 Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13

I also have several events, most of them are from an Android or Facebook browser. Even Facebook 95.0, which should be recent, is triggering this error. Android 4.. is the main OS and many of the devices where it's reported are Samsung-GT[something]. I'm using the 3.7.0 version.

We have gotten this as well from a super generic user agent, no special devices:

Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36

Raven 3.9.0

still happens on 3.9.1 a few hundred times a day, on facebook & android browser.name
no stack trace whatsoever.

should we just ignore it ?

Same here.

Same just like everyone here. If this info helps:

image

UA: Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; GT-I8190L Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 [FB_IAB/FB4A;FBAV/87.0.0.17.79;]

Browser: Facebook 87.0.0

the same here, any solution?? :S

I have same issue

image

I'm currently have the same issue... there are a lot of this errors and I'm reaching sentry threshold very soon 😞

I'm getting dozens of these issues, all with Chrome 45 on Windows 10.

It's still happening on raven 3.15.0, on facebook & android browser
Should we just ignore it?

Anyone found a solution? In my case appears this in sentry:

`[object Event]

at trimHeadFrames(./node_modules/raven-js/src/raven.js:562:1)
at _logDebug(./node_modules/raven-js/src/raven.js:488:1)
at G._promiseRejectionHandler(./node_modules/raven-js/src/raven.js:430:1)`

unhandledPromiseRejection: true

User agent: Mozilla/5.0 (Linux; U; Android 6.0.1; en-US; vivo 1610 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.5.8.1112 Mobile Safari/537.36

Device family: vivo 1610
Device model: 1610
Device brand: vivo

Android 6.0.1

UC Browser 12.5.8

My raven-js client version is: 3.25.0

I attached a screenshot of the error (happens many times with many old browsers)
raven-screenshot

This is fixable in new SDK using event hints and custom error handling.

@kamilogorek

This is fixable in new SDK using event hints and custom error handling.

Can you elaborate this? Any links to document?
At least which version we need?
I prefer to have code snippet of those "event hints" and "custom error handling" settings for this issue.

Thanks!

@hiroshi please see https://github.com/getsentry/sentry-javascript/issues/1401#issuecomment-418631326
It's a feature of new sentry-javascript SDK, which has been released as a RC Today. It won't be ported back to raven-js/node.

Hi, I keep seeing an error like this in Sentry:

exception | Error: [object Event]

There's no stack trace attached and no helpful information. From LogRocket sessions, it appears user experiences no problems. I do see some blocked requests to Facebook and Google Tag Manager, so I suspect they have a blocker extension installed.
It's a recurring error from a person using Chrome 75, not a very old browser.
Any suggestions how I'd clear up this issue?

Thanks

Note: @sentry/browser version 5.3.0

@burtyish updating to the latest version is the first good step. We introduced _a lot_ of changes regarding this behavior in 5.7.0

@kamilogorek Thanks!
I see a much more informative error now that I've upgraded to sentry.javascript.browser v5.12.1.
And I've got a stack trace too!

@burtyish awesome! :)

Was this page helpful?
0 / 5 - 0 ratings