Originally posted May 3 2010
- Function recursively calls itself.
- Since the caller property is attached to the function itself there is no way of knowing (through this information alone) how many times the function was called.
- Function A calls function B, which then calls function A…
- Even if there are terminating condition, the code that attempts to reconstruct the stack trace (using “callee” and “caller”) will not terminate. There is a good description of this behavior here.
I was primarily interested in scenario 2, since this can cause errors. To get around this you can detect that you have already encountered a given function and simply stop. Of course this means that you lose any information that follows, but at least you won’t hang the browser.
Conclusion: always check MDC :)