-
Notifications
You must be signed in to change notification settings - Fork 3
Description
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.