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.