quickjs icon indicating copy to clipboard operation
quickjs copied to clipboard

Fewer <anonymous> functions in stack traces?

Open swankjesse opened this issue 4 years ago • 4 comments

Here’s a program that makes a stack trace:

var dog = {};
dog.bark = function() {
  throw new Error('woof woof');
};
function makeStack() {
  try {
    dog.bark();
  } catch (error) {
    return error.stack;
  }
}
makeStack();

This is what QuickJS makes:

    at <anonymous> (file.js:3)
    at makeStack (file.js:7)
    at <eval> (file.js:12)

And Chrome:

Error: woof woof
    at Object.dog.bark (file.js:3:9)
    at makeStack (file.js:7:9)
    at file.js:12:1

And Firefox:

[email protected] eval code:3:9
[email protected] eval code:7:9
@file.js eval code:12:1

Both Chrome and Firefox include dog.bark in the stack trace, but in QuickJS this function is <anonymous>.

Getting the function name in the output is super handy. This example is trivial, but my real program has deep stacks full of <anonymous> and it slows down debugging.

swankjesse avatar Sep 25 '21 01:09 swankjesse

(QuickJS still puts Safari to shame though!)

@
makeStack@
global code@
evaluateWithScopeExtension@[native code]
@
_wrapCall@

swankjesse avatar Sep 25 '21 01:09 swankjesse

Is there any progress on this issue?

wanhongbo avatar Apr 11 '22 03:04 wanhongbo

Not yet, currently focusing on other issues: ropes, bug fixes and support for recent tc39 extensions.

Chqrlie.

On 11 Apr 2022, at 05:07, Hongbo Wan @.***> wrote:

Is there any progress on this issue?

— Reply to this email directly, view it on GitHub https://github.com/bellard/quickjs/issues/93#issuecomment-1094495816, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE5F5KWHGAJFSADQMZRM5FTVEOJOJANCNFSM5EXALPYQ. You are receiving this because you are subscribed to this thread.

chqrlie avatar Apr 11 '22 07:04 chqrlie

function makeStack() { try { this.xxxx() } catch (error) { console.log(error.stack) console.log(error.message) } } makeStack();

The above code does not display xxxx in call stack when it fails :(

wanhongbo avatar Apr 13 '22 10:04 wanhongbo