Advice for tracking down difficult to find bugs

I’m working on an app with 1000’s of lines of code and I’m trying to track down these errors:

The error messages don’t provide any information as to what functions are causing the errors.

I’ve already spent about an hour going through the files which I thought might be causing them.

I could always reset back commits to find it, but I think these errors have been around several weeks.

Any advice on tracking down the culprits? Is there any type of flag or environment variable that I can set that will provide me with more information?

1 Like

You actually get quite a lot of info by that error.

First it says it can’t read the property name of undefined, meaning you are accessing someobject.name somewhere. A first thing you could try is searching your whole project for “.name” (without quotes). Might turn up a lot of results, or might turn up only a few. To actually find the .name that’s causing the issue. Just do a console.log on the object itself right before you access it’s name property. If it returns null or undefined at some point you know that’s the culprit (or one of them)

Secondly, those exceptions mostly pop up when you’re working in rendered or destroyed callbacks from templates. In other words, chances are high that you can narrow your search down to “.name” inside rendered or destroyed callbacks.

As to fixing the bug, that depends on the actual code and context. Might be as simple as checking the type of the object before accessing it’s name property and if it’s null aborting the code that follows, but might also be somewhat more complex.

You should be able to track it down with this info, if you have problems resolving the bug, feel free to post the code that’s causing the errors.

1 Like

Try kadira’s error reporting view for that. It provides much more info, at least for certain errors, not sure if for all of them. Under the hood it uses zones.js (that began life in angular) in order to crreate and track meaningful contexts while running in an async environment. See if that helps if you haven’t tried that yet.

1 Like

Thanks @nlammertyn! Appreciate the help.

I don’t know why, but the properties name “name” was throwing me off, and I was completely overlooking it.

Found the error in two seconds after I read your reply.

Cool @seeekr. I didn’t realize that kadira’s error reporting showed more info than what the console displays. That’ll come in handy.

1 Like