3

What browsers support Error.stackTraceLimit, 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...

1 Answer 1

8

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(){ secondFunction(); } function secondFunction(){ thirdFunction(); } function thirdFunction(){ fourthFunction(); } function fourthFunction(){ throw new Error("xxxx"); } try { firstFunction(); } 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 https://msdn.microsoft.com/en-us/library/s4esdbwz(v=vs.94).aspx .
  • 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.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.