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

Old browsers cause [object Event] to be logged #360

Closed
asbjornu opened this issue Aug 3, 2015 · 50 comments
Closed

Old browsers cause [object Event] to be logged #360

asbjornu opened this issue Aug 3, 2015 · 50 comments

Comments

@asbjornu
Copy link

asbjornu commented Aug 3, 2015

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.

@asbjornu
Copy link
Author

asbjornu commented Aug 3, 2015

One particular sample from our logs show the following information:

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

@benvinegar
Copy link
Contributor

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.

@bnjmnt4n
Copy link
Contributor

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.

@benvinegar
Copy link
Contributor

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

@Morpho
Copy link

Morpho commented Nov 27, 2015

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

@sonthonaxrk
Copy link

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.

@benvinegar
Copy link
Contributor

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

@Morpho
Copy link

Morpho commented Jan 28, 2016

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

@sonthonaxrk
Copy link

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.

@benvinegar
Copy link
Contributor

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.

@sonthonaxrk
Copy link

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

@benvinegar
Copy link
Contributor

Cool. Again, I appreciate you digging into this.

@sonthonaxrk
Copy link

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

@benvinegar
Copy link
Contributor

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.

@benvinegar
Copy link
Contributor

@rollokb – any news on this?

@dani3l
Copy link

dani3l commented Jun 16, 2016

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

@gkorland
Copy link

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

@benvinegar
Copy link
Contributor

benvinegar commented Jul 18, 2016

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.

@gkorland
Copy link

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

@webschik
Copy link

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

@AlexanderMatveev
Copy link

+1 for this

@benvinegar
Copy link
Contributor

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.

@AlexanderMatveev
Copy link

@benvinegar I have 3.7.0 installed, but getting this error

@webschik
Copy link

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);
     }

@AlexanderMatveev
Copy link

AlexanderMatveev commented Sep 23, 2016

@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

@AlexanderMatveev
Copy link

@webschik

2016-09-23 12 45 43

@webschik
Copy link

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

@AlexanderMatveev
Copy link

AlexanderMatveev commented Sep 23, 2016

@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
Copy link
Contributor

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

@yurynix
Copy link

yurynix commented Sep 26, 2016

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

@danielcardoso5
Copy link

danielcardoso5 commented Oct 13, 2016

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.

@TheSavior
Copy link
Contributor

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

@dani3l
Copy link

dani3l commented Dec 26, 2016

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 ?

@seeden
Copy link

seeden commented Jan 5, 2017

Same here.

@rfviolato
Copy link

rfviolato commented Jan 5, 2017

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

@riqui99
Copy link

riqui99 commented Jan 17, 2017

the same here, any solution?? :S

@avdeev
Copy link

avdeev commented Feb 9, 2017

I have same issue

image

@danieleleoni
Copy link

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

@sibblegp
Copy link

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

@quique0194
Copy link

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

@devcorpio
Copy link

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

@kamilogorek
Copy link
Contributor

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

@hiroshi
Copy link

hiroshi commented Sep 5, 2018

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

@kamilogorek
Copy link
Contributor

@hiroshi please see #1401 (comment)
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.

@burtyish
Copy link

burtyish commented Feb 9, 2020

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

@kamilogorek
Copy link
Contributor

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

@burtyish
Copy link

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

@kamilogorek
Copy link
Contributor

@burtyish awesome! :)

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

No branches or pull requests