Created
March 11, 2011 15:32
-
-
Save jmar777/866025 to your computer and use it in GitHub Desktop.
In-descriptive Max Recursion Errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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