dougwilson / nodejs-depd

Deprecate all the things
MIT License
325 stars 87 forks source link

Rapidly calling Error.captureStackTrace eventually results in empty stack #10

Closed dougwilson closed 10 years ago

dougwilson commented 10 years ago

In v8, when rapidly calling Error.captureStackTrace, an empty stack trace will end up being returned. This module needs to handle that case.

dougwilson commented 10 years ago

Strangely this only seems to happen when using the Error.captureStackTrace(obj, fn) form, where fn is a set function name.

dougwilson commented 10 years ago

Scratch that; there just seems to be some weird side-effects going on (not sure if this is a v8 bug, but that doesn't matter to Node.js even if it is because it'll just never get fixed :) ). Adding an enormous for loop to slow it down has no effect, but accessing arguments.callee within the body will magically fix it (but not other properties of arguments). This makes it seem like the bug is that for some reason, it will not think the stack contains the calling function under weird conditions, thus the stack gets chopped down to zero length.

dougwilson commented 10 years ago

The simplest solution for now is to not have Error.captureStackTrace limit the stack and instead manually slice off the top.