tc39/proposal-error-stacks

Name: proposal-error-stacks

Owner: Ecma TC39

Description: ECMAScript Proposal, specs, and reference implementation for Error.prototype.stack / System.getStack

Created: 2016-10-24 22:23:20.0

Updated: 2018-05-14 13:01:22.0

Pushed: 2017-10-21 15:54:58.0

Homepage: https://tc39.github.io/proposal-error-stacks/

Size: 88

Language: HTML

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Error Stacks

ECMAScript Proposal, specs, and reference implementation for Error.prototype.stack/System.getStack/System.getStackString

Spec drafted by @ljharb along with @erights.

This proposal is currently stage 1 of the process.

Rationale

Errors have never had a stack trace attached in the language spec ? however, implementations have very consistently provided one on a property named ?stack? on instantiated Error objects. There has long been concern about standardizing stack traces improperly - such that implementations could not claim to be fully compliant while also providing security guarantees. This proposal is an attempt to standardize the intersection of existing browser behavior, in a way that addresses these security concerns.

Compatibility
ct.getOwnPropertyDescriptor(new Error(), 'stack');
ct.getOwnPropertyDescriptor(Error.prototype, 'stack');

V8 in Node 7+ and Chrome 54+: stack is an own property on Error instances which claims to be a value property ({"value":"(stack here)","writable":true,"enumerable":false,"configurable":true), but V8's Error has exotic behavior for [[GetOwnProperty]] that acts like a getter the first time (if there's been no set first) by triggering prepareStackTrace and setting stack, as discussed in this thread. After that, it behaves like a standard value property.

V8 in Node <= 6 and Chrome <= 53: stack is an own property on Error instances with a getter/setter: { configurable: true, enumerable: false }

Safari: stack is an own string data property on Error instances: { configurable: true, enumerable: false, writable: true }

Firefox: stack is an own property on Error.prototype: { configurable: true, enumerable: false }

Naming

Error.prototype.stack is set in stone - this is a defacto reality, and will be implemented in Annex B.

Spec

You can view the spec in markdown format or rendered as HTML.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.