csnover / TraceKit

Attempts to create stack traces for unhandled JavaScript exceptions in all major browsers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read property 'tagName' of null

cseufert opened this issue · comments

I have sentry.io setup, but my errors are being gobbled up by errors in TraceKit. I have no idea how to reproduce it, but its coming from chrome 65 on windows 10 via some sort of mouse event.

Hello, Were you able to figure out what was causing this?

It appears like TraceKit is throwing it trying to resolve the event.target, but when you look at the code it can't be the case (there is a test if target exists, and then tagName exists on target), however the line number of the throw is consistently inside the TraceKit minified blob within sentry.io

Short answer, No, I'm hoping at some point sentry.io pull in the latest TraceKit, and maybe that will solve the issue?

Have you reached out to them?

Nah, haven't contacted them, being I'm just using their free plan.

Interestingly, sentry is now pointing into its own code with this error now.
./node_modules/@sentry/browser/dist/index.js in HTMLDocument.n at line 3197:1

            var wrappedArguments = args.map(function (arg) { return wrap(arg, options); });
            if (fn.handleEvent) {
                return fn.handleEvent.apply(this, wrappedArguments);
            }
            else {
               return fn.apply(this, wrappedArguments); /* <<< This Line */
            }
        }
        catch (ex) {
            ignoreNextOnError();
            core.withScope(function (scope) { return tslib_1.__awaiter(_this, void 0, void 0, function () {

And it looks as if the event that is causing this issue is originating from a click on an SVG element.

They source import it and have a few changes of their own. I try to sync them when I get some free time, they really should be better oss citizens as we all win.

We wrap various event handlers with error handling, maybe this is what you are seeing. If you could post the full unminified stack trace it would be helpful. That seems really weird, if you are able to narrow this down could you add a test to our unit tests for this use case.

The issue is I don't know how to reproduce the error in my app. Sentry.io only report this error as the error, which I believe is during it attempting to get a stack trace.

So all I get is something like this:

TypeError: Cannot read property 'tagName' of null
  at HTMLDocument.n(./node_modules/@sentry/browser/dist/index.js:3197:1)

I don't see anywhere in our code (https://github.com/csnover/TraceKit/blob/master/tracekit.js) where we call any property called tagName. Which makes me feel like it's something that happening in the sentry libs. I'm guessing we are in the stack trace because we are wrapping various window functions in try catch logic and reporting those.