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?
If I create a program that looks like this an run it
const recurse = (num=0) => {
console.log('level ' + num);
recurse(++num)
}
recurse()
Node will eventually bail out of the program with this error
//...
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) => {
console.log('level ' + num);
recurse(++num)
}
recurse()
The level/depth at which it bails out varies (usually in the 10,000 - 13,000 range). This error message tells me the call stack size (not the depth) is the problem, but it's unclear what size is here (I presume some internal to node data structure size).
What I'd like to know is -- does node allow me to
- View/Set the size at which this call stack protection kicks in
- View/set a depth limit for the call stack.
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.