Skip to content

Instantly share code, notes, and snippets.

@jmar777
Created March 11, 2011 15:32
Show Gist options
  • Save jmar777/866025 to your computer and use it in GitHub Desktop.
Save jmar777/866025 to your computer and use it in GitHub Desktop.
In-descriptive Max Recursion Errors
/*
How do we provide more descriptive error messages for max-recursion situations?
*/
var depth = 0;
(function recurseBaby() {
// log at every 500 calls
(++depth % 500) || console.log(depth);
// bail out ~100K depth in case you're special and don't error out
if (depth > 100000) return;
recurseBaby();
})();
/*
Output in v0.2.6:
...
15500
16000
node.js:63
throw e;
^
*/
/*
Output in v0.4.2:
...
18000
18500
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
undefined
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment