title: NodeJS and CallStack Size Protection
body: <p>Does NodeJS offer the ability to view or set any limits (at run time or via CLI flags?) for the size of the call stack?</p>
  
  <p>If I create a program that looks like this an run it</p>
  
  <pre><code>const recurse = (num=0) =&gt; {
    console.log('level ' + num);
    recurse(++num)
  }
  recurse()
  </code></pre>
  
  <p>Node will eventually bail out of the program with this error</p>
  
  <pre><code>//...
  level 12021
  _stream_readable.js:872
  Readable.prototype.removeListener = function(ev, fn) {
                                              ^
  
  RangeError: Maximum call stack size exceeded
      at WriteStream.Readable.removeListener (_stream_readable.js:872:45)
      at write (console.js:172:12)
      at Console.log (console.js:200:3)
      at recurse (/path/to/so.js:2:11)
      at recurse (/path/to/so.js:3:3)
      at recurse (/path/to/so.js:3:3)
      at recurse (/path/to/so.js:3:3)
      at recurse (/path/to/so.js:3:3)
      at recurse (/path/to/so.js:3:3)
      at recurse (/path/to/so.js:3:3)
  C02V30M6HTDG:test-express-app astorm$ cat so.js 
  const recurse = (num=0) =&gt; {
    console.log('level ' + num);
    recurse(++num)
  }
  recurse()
  </code></pre>
  
  <p>The <em>level/depth</em> at which it bails out varies (usually in the 10,000 - 13,000 range).  This error message tells me the call stack <em>size</em> (not the depth) is the problem, but it's unclear what size is here (I presume some internal to node data structure size).</p>
  
  <p>What I'd like to know is -- does node allow me to</p>
  
  <ol>
  <li>View/Set the size at which this call stack protection kicks in</li>
  <li>View/set a depth limit for the call stack.  </li>
  </ol>
  
  <p>I don't have any particular problem in mind to solve, I'm just trying to understand how much control NodeJS gives me vs. other languages I've worked with. </p>