API to get stack frame info from generator

Bruno Jouhier bjouhier at gmail.com
Fri Jun 14 15:32:48 PDT 2013

Thanks David. The problem is that I need it first in node.js, and if
possible with a standardized API that works in all ES6 JS engines.

I see this as being similar to asking for a portable "stack" property in
Error objects. I don't know if it is actually mandated by ES6 but it looks
like all major JS engines support it now.

Note that caller and callee would not work for my use case. I need the
frame info for a generator object which has been suspended, not from the
generator function itself.

2013/6/14 David Bruant <bruant.d at gmail.com>

> Le 14/06/2013 16:56, Bruno Jouhier a écrit :
>  I'm using ES6 generators to implement a little async/await library and
>> I'm quite pleased with the result so far but I'm lacking one API: a
>> function to get stack information from a generator object. Ideally it would
>> return the name of the current generator function, the filename and the
>> line number where it last yielded.
>> If I had this API I 'd be able to provide a complete trace of the stack
>> of await calls when an exception is caught.
> ES5 strict mode poisoned .caller and .callee. The reason is that it isn't
> necessarily a good idea (security, maybe performance reasons as well) to
> give authority to the runtime to inspect stack frames. It's more of a
> debugger use case.
> The Debugger API in Firefox (only available to "Chrome-level" privileged
> code) has a way to know the function being called, and to navigate across
> the different frames like the caller frame ("older" property) [1] and some
> infos that help finding the function name, filename and line number.
> David
> [1] https://developer.mozilla.org/**en-US/docs/SpiderMonkey/JS_**
> Debugger_API_Reference/**Debugger.Frame<https://developer.mozilla.org/en-US/docs/SpiderMonkey/JS_Debugger_API_Reference/Debugger.Frame>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130615/2bf2ce41/attachment.html>

More information about the es-discuss mailing list