Skip to content

Fewer <anonymous> functions in stack traces? #93

Open
quickjs-ng/quickjs
#844
@swankjesse

Description

@swankjesse

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:

dog.bark@file.js eval code:3:9
makeStack@file.js 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions