error in stacktrace API documentation
Reported by
potoms....@gmail.com,
Dec 29 2016
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36
Steps to reproduce the problem:
execute:
Error.prepareStackTrace = function (error, structStackTrace) { return typeof structStackTrace[0].getEvalOrigin() }
eval('new Error().stack')
What is the expected behavior?
getEvalOrigin returns CallSite object according to https://github.com/v8/v8/wiki/Stack-Trace-API#customizing-stack-traces
What went wrong?
it returns a string
Did this work before? N/A
Chrome version: 55.0.2883.95 Channel: stable
OS Version: OS X 10.12.2
Flash Version: Shockwave Flash 24.0 r0
,
Jan 9 2017
,
Feb 15 2018
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Feb 15 2018
,
Feb 16 2018
Thanks for reporting, updated the wiki.
,
Feb 16 2018
I'd say this is rather an error in the API than in the documentation, since it would be more useful to have the CallSite in a structured form than a string that has to be parsed. It also would allow for to be called recursively in the case of nested eval's
,
Feb 20 2018
I'm not sure I understand what you want to achieve, do you have an extended code example?
With nested evals, information about the caller is in the next CallSite object. For example:
d8> eval("eval(\"throw new Error();\");")
Error
at eval (eval at <anonymous> (eval at <anonymous> ((d8):1:1)), <anonymous>:1:7)
at eval (eval at <anonymous> ((d8):1:1), <anonymous>:1:1)
at (d8):1:1
structuredStackTrace[0] shows the top frame, structuredStackTrace[1] its caller.
But the eval origin doesn't necessarily have to be on the call stack:
d8> eval("g = function() { throw new Error(); }");
d8> g()
Error
at g (eval at <anonymous> ((d8):1:1), <anonymous>:1:24)
at (d8):1:1
CallSite objects are intended to give information about a function on the call stack.
Returning a String for the eval origin seems reasonable to me since the eval origin
may not be on the call stack.
,
Feb 20 2018
No, that makes sense |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by brajkumar@chromium.org
, Dec 30 2016Labels: M-57 OS-Linux OS-Windows
Status: Untriaged (was: Unconfirmed)