Skip to content

Structured stack traces for diagnostics messages #96

@bcheidemann

Description

@bcheidemann

V8 exposes two APIs to access stack traces (see https://v8.dev/docs/stack-trace-api).

Error.prepareStackTrace is a low-level API which is generally implemented by runtimes. This gets access to the raw structured stack trace, and returns a serialised stack trace. Runtimes usually use this to implement source map resolution.

Error.captureStackTrace is a (slightly) higher level API which can be used to generate a serialised stack trace. This will result in Error.prepareStackTrace being called, and the result being set as the value for the target.stack property.

We currently use Error.captureStackTrace when reporting diagnostics, but this requires us to do some ugly (and fragile) string manipulation to remove parts of the serialised stack trace which we aren't interested in. It also does not give reporters much control over how stack traces are reported.

It may be beneficial to use the Error.prepareStackTrace to get a raw structured V8 stack trace, as this imposes fewer limitations moving forward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions