Search code examples
javascriptfirefoxfirefox-developer-tools

Javascript stack traces come up empty


The stack traces shown in the Firefox Console are always empty. Am I missing something or might this be a Firefox bug?

Example JS:

function foo() {
    bar()
}
function bar() {
    console.trace()
}
foo()

Resulting output: enter image description here

(Using FF 59 for Ubuntu)


Solution

  • This is probably a bug in Firefox 59.0.2, which is already fixed in Firefox Nightly 61.0a1 (2018-04-23).

    Stack trace in Browser Console

    Having said that, you just need to make sure where you execute your code. When you execute your code within Scratchpad and check the results within the Browser Console, it might not work as expected. Though when you check the Web Console, the stack trace is shown correctly.

    Alternatively, there is also the possibility to run your code within the browser context to get the expected results.

    Stack trace of executing code in browser context shown in Browser Console