public
Last active

  • Download Gist
stack-exceed.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
var stackLimit = (function() {
var result = 0;
 
function recurse() {
result++;
recurse();
}
try {
recurse();
} catch(e) { }
return result;
}());
 
var o = {
'foo': function() {
return this;
}
};
 
global.onerror = function(message) {
console.log(message);
};
console.log('About to start the test');
var foo = Function('return o.foo()' + Array(stackLimit + 1).join('.foo()'))();
console.log(foo);
About to start the test

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
RangeError: Maximum call stack size exceeded

I typoed, should be:

var foo = Function('return o.foo()' + Array(stackLimit + 1).join('.foo()'))();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.