inf3rno inf3rno - 6 months ago 55
Javascript Question

Error.stackTraceLimit cross-browser

What browsers support

, from which versions? Are there any alternative APIs to limit stacktrace length?

Afaik. it is supported from IE10, and by current V8: Node, Chrome, but I don't know more about it. I guess it is non standard like other parts of the Error APIs. I did not find anything about alternative methods to set the trace length in different browsers than these. So I need more info about this feature, but I did not find much using google...


It is hard to find relevant information in this topic, at least google did not help me, so I had to write a simple test.

function testStackTraceLimitSupport(){
    Error.stackTraceLimit = 2;

    function firstFunction(){
    function secondFunction(){
    function thirdFunction(){
    function fourthFunction(){
        throw new Error("xxxx");

    try {
    } catch (error){
        return !/firstFunction/.test(error.stack) 
            && !/secondFunction/.test(error.stack) 
            && /thirdFunction/.test(error.stack) 
            && /fourthFunction/.test(error.stack);

console.log("Error.stackTraceLimit support: ", testStackTraceLimitSupport());

As far as I know there are no alternative ways to set the trace length limit from javascript code. All you can do to slice the stack if you want it to be shorter.

I tested the feature on the following environments.

  • Node - Tested on 4.2.1, it was supported. I did not find version data, probably it is in the Chromium docs.
  • Chrome - Tested on 52.0.2743.116 m, it was supported. I did not find version data, probably it is in the Chromium docs.
  • Firefox - Tested on 48.0.2 it was not supported.
  • Internet Explorer - Tested on 11.0.9600.18426, it was supported. It is supported by IE10+ and Edge as well .
  • Opera - Tested on 39.0.2256.71, it was supported. I did not find any Opera documentation for javascript developers.
  • PhantomJS - Tested on 2.1.1 it was not supported.