Skip to content

Causes observable changes with prepareStackTrace #8

@o-

Description

@o-

When requiring the stack properties value to be eagerly evaluated in captureStackTrace there is a problematic interaction with the existing accompanying prepareStackTrace. That one allows arbitrarily formatting of the stack trace attached to the error object. This makes it observable when the string content of the stack property is computed.

The proposal here would require eager evaluation of the stack formatting code at captureStackTrace time. Whereas the current implementation does it lazily.

Error.prepareStackTrace = (error, stack) => {console.log("2. prepare")};
let err = {}; 
Error.captureStackTrace(err);
console.log("1. capture");
err.stack;

Here we would essentially have to swap the order of effect 1 and 2.

I think this is not just a theoretical issue. Next to an observable change in behavior it would also make the prepareStackTrace API prohibitively expensive to use.

There is evidence of effectfull and expensive prepareStackTrace handlers, see e.g., source-map-support for node.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions