getOwnPropertyDescriptor side effects

Jordan Harband ljharb at
Thu Jan 19 07:33:32 UTC 2017

The beginnings of the Error Stacks proposal is now up at

I'm presenting it this month at TC39, hoping for it to be stage 1.

As its stands, the proposal would indeed make v8's behavior noncompliant,
were it to become stage 4.

On Thu, Jan 12, 2017 at 1:04 PM, Isiah Meadows <isiahmeadows at>

> Okay, so it's a V8 bug. Filed it here:
> v8/issues/detail?id=5834
> On Thu, Jan 12, 2017, 03:03 T.J. Crowder <tj.crowder at>
> wrote:
>> So to sum up, then, and circle back to Francisco Tolmasky's original
>> question:
>> * For ordinary objects, `Object.getOwnPropertyDescriptor` shouldn't
>> have side-effects because none of the ordinary operations it uses has
>> side effects.
>> * For exotic objects, it may well have side effects as a result of an
>> exotic version of [[GetOwnProperty]]; for instance, Adam Klein's
>> `Proxy` example.
>> * `Error` objects are specified as ordinary objects.
>> * V8's `Error` object has a `stack` property that claims to be a value
>> property (not an accessor).
>> * V8's `Error` object is a exotic object, it has exotic behavior for
>> [[GetOwnProperty]], because it triggers filling in the string for the
>> captured stack trace if you call it for `stack` (it has to, in order
>> to provide the `value` property of the descriptor, since `stack`
>> claims to be a value property).
>> * This aspect of V8's `Error` could be in-spec by making `stack` an
>> accessor instead (or by building the string earlier, but it's deferred
>> for performance reasons).
>> Is that a reasonable summary?
>> Additionally, I believe the only exotic object defined by the
>> specification that has a [[GetOwnProperty]] with potential side
>> effects is `Proxy`.
>> Provided that's all correct, Francisco's answer is: Per spec, you
>> can't rely on `Object.getOwnPropertyDescriptor` not having side
>> effects unless you can guarantee you're not dealing with a `Proxy`.
>> Per spec, you could for non-`Proxy` objects defined by the
>> specification, but that's not currently the case with V8 (at least).
>> And there's always the possibility of host objects having exotic
>> [[GetOwnProperty]] behavior.
>> -- T.J.
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list