tc39 / proposal-error-stacks

ECMAScript Proposal, specs, and reference implementation for Error.prototype.stack / System.getStack
https://tc39.github.io/proposal-error-stacks/
MIT License
170 stars 13 forks source link

Could we do less (initially) in this proposal? #49

Open mgaudet opened 6 days ago

mgaudet commented 6 days ago

I think we need to talk about stacks in the spec. I am partially motivated by the fact that I forsee shortly having to write spec text for Error.captureStackTrace, and there’s no real place to hang this off at the moment.

However, the spec text as it exists in the repo today is probably too far.

So then how to proceed? My personal take is that this proposal should simply be “Stacks exist”; provide a minimal amount of (potentially Annex B) text which indicates Errors may have a stack property.

If it’s compatible, I know SES would prefer V8 have an accessor on the Error prototype, so perhaps if we could get that speced. As to the return value of that getter, I think the text should simply read “An implementation defined string representation of the execution context stack”

ljharb commented 6 days ago

I believe that wouldn't meet a lot of the motivating needs: to be able to delete the stack accessor, and then (Compartments-style) provide a shadowed getStackString implementation (that brand-checks and throws, unlike the accessor).

The getStack API is indeed not strictly necessary, but it is a massive convenience, and the thing that virtually everyone who I've spoken to about this proposal is excited about. In other words, developers desperately want to work with structured data, and stacks currently are just an opaque string that people have to commit atrocities in order to introspect.