1 of 7

Proposal: Error.captureStackTrace

Daniel Minor @ Mozilla

2 of 7

Motivation

From MDN: The Error.captureStackTrace() static method installs stack trace information on a provided object as the stack property.

3 of 7

History

4 of 7

Work in Stage 1

Because browsers have already shipped, the design space is very small

Feedback from committee last time:

  • Strong preference to install a property rather than an accessor
  • No special behaviour for objects with an [[ErrorData]] slot

Investigated requiring the optional `constructor` argument to be callable:

  • Telemetry showed about 0.8% of calls would be broken, doesn’t seem worth the risk

5 of 7

Proposed Specification

6 of 7

Issue #8: Causes observable changes with prepareStackTrace

  • `prepareStackTrace` is a non-standard V8 API that allows custom formatting of the stack
  • Currently, V8’s implementation uses a getter and lazily computes the stack, so `prepareStackTrace` isn’t called unless needed
  • As specified, using a property would cause this to be computed eagerly, which could be expensive and change observable ordering, depending on what `prepareStackTrace` does

7 of 7

Consensus for

Stage 2?

Source: https://en.wikipedia.org/wiki/File:River_terrapin.jpg