5

I am doing a web application. In Firefox, I am able to use Web Developer's Debugger tool.

In my Javascript code, I got the error in Firefox

TypeError: a is undefined

The above error happened in jQuery.

I know that the data I pass to jQuery is not right. However, there are many jQuery calls in my code and I don't know which call leads to this error.

Anyway to show the stack of calls that lead to an error via Debugger? The way Java shows error stack trace?

Thanks!

curious1
  • 14,155
  • 37
  • 130
  • 231
  • This is the main reason I do most of my debugging in Chrome—it saves the stack for error messages. Unfortunately, Firefox is more pedantic about Javascript syntax (which is not a bad thing), so I very often end up with errors in Firefox that I don't get in Chrome. – Michael Scheper Jun 24 '15 at 19:37

2 Answers2

2

Here is what I did.

Use development version of jQuery (not the file with min in it).

Find the error line in jQuery. Before it, insert the following:

console.trace();

console.trace() shows the trace.

I am not sure whether there is any easier way.

Hope this helps someone else.

Cheers.

curious1
  • 14,155
  • 37
  • 130
  • 231
  • 1
    Thanks for sharing man I didn't know this! If you enable all the developer preferences though it should put out a long string in error console which shows what line it came from. – Noitidart Nov 14 '14 at 06:00
  • Noitidart, could you please detail "If you enable all the developer preferences though it should put out a long string in error console which shows what line it came from."? Could you please directly add it to my answer? Your input will make a better answer. – curious1 Nov 14 '14 at 14:32
  • 1
    try enabling these prefs. i never had the need to use trace, the console always shows in detail where the error was, im not sure which pref is responsible for it though. https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment?redirectlocale=en-US&redirectslug=Setting_up_extension_development_environment#Development_preferences – Noitidart Nov 14 '14 at 15:59
2

July 2018 UPDATE

Context: I bumped into this question because I couldn't find the stacktrace in the Debugger tool of the FF console anymore (FF 61).

In the many versions that followed, at the epoch of the original question, the stack trace was obvious to see in the console (F12). But despite what is being said today in the official documentation for FF42+ (see https://developer.mozilla.org/en-US/docs/Tools/Debugger), I am not able to see the Call Stack tab anymore in the console of Firefox 61. The trick is to revert to the old debugging front-end, by following their hint:

set "devtools.debugger.new-debugger-frontend" preference to false in the about:config section of the browser.

Restart, and the Call Stack tab should then appear on the left of the Debugging console (see image attached).enter image description here

Fabien Haddadi
  • 1,814
  • 17
  • 22