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 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 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
Member

@benvinegar benvinegar commented Nov 11, 2015

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

@bnjmnt4n bnjmnt4n commented Nov 23, 2015

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
Member

@benvinegar benvinegar commented Nov 23, 2015

@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 Morpho commented Nov 27, 2015

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

@sonthonaxrk
Copy link

@sonthonaxrk sonthonaxrk commented Jan 27, 2016

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
Member

@benvinegar benvinegar commented Jan 27, 2016

@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 Morpho commented Jan 28, 2016

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

@sonthonaxrk
Copy link

@sonthonaxrk sonthonaxrk commented Jan 28, 2016

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
Member

@benvinegar benvinegar commented Jan 28, 2016

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

@sonthonaxrk sonthonaxrk commented Jan 28, 2016

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
Member

@benvinegar benvinegar commented Jan 28, 2016

Cool. Again, I appreciate you digging into this.

@sonthonaxrk
Copy link

@sonthonaxrk sonthonaxrk commented Jan 28, 2016

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
Member

@benvinegar benvinegar commented Jan 28, 2016

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
Member

@benvinegar benvinegar commented Feb 17, 2016

@rollokb – any news on this?

@dani3l
Copy link

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

@gkorland gkorland commented Jul 18, 2016

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

@benvinegar
Copy link
Member

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

@gkorland gkorland commented Jul 18, 2016

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

@webschik
Copy link

@webschik webschik commented Aug 11, 2016

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

@AlexanderMatveev AlexanderMatveev commented Sep 22, 2016

+1 for this

@benvinegar
Copy link
Member

@benvinegar benvinegar commented Sep 22, 2016

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

@AlexanderMatveev AlexanderMatveev commented Sep 23, 2016

@benvinegar I have 3.7.0 installed, but getting this error

@webschik
Copy link

@webschik webschik commented Sep 23, 2016

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

@AlexanderMatveev AlexanderMatveev commented Sep 23, 2016

@webschik
Copy link

@webschik webschik commented Sep 23, 2016

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

@benvinegar
Copy link
Member

@benvinegar benvinegar commented Sep 23, 2016

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

@TheSavior TheSavior commented Dec 15, 2016

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 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 seeden commented Jan 5, 2017

Same here.

@rfviolato
Copy link

@rfviolato 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 riqui99 commented Jan 17, 2017

the same here, any solution?? :S

@avdeev
Copy link

@avdeev avdeev commented Feb 9, 2017

I have same issue

image

@danieleleoni
Copy link

@danieleleoni danieleleoni commented Mar 20, 2017

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

@sibblegp sibblegp commented Apr 24, 2017

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

@quique0194
Copy link

@quique0194 quique0194 commented Jun 9, 2017

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

@devcorpio
Copy link

@devcorpio devcorpio commented Jun 17, 2018

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
Member

@kamilogorek kamilogorek commented Sep 4, 2018

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

@kamilogorek kamilogorek closed this Sep 4, 2018
@hiroshi
Copy link

@hiroshi 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
Member

@kamilogorek kamilogorek commented Sep 5, 2018

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

@kamilogorek kamilogorek commented Feb 10, 2020

@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

@burtyish burtyish commented Feb 11, 2020

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

@kamilogorek kamilogorek commented Feb 11, 2020

@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet