Skip to content

module: add API for interacting with source maps

Background

When we introduced our own prepareStackTrace for rewriting stack traces based on source maps, we removed support users to provide a custom Error.prepareStackTrace...

V8 documents the Error.prepareStackTrace API surface and given feedback we've received, see #29994 (closed), it seems like this was the wrong design decision....

Unfortunately, since we don't expose the source map cache Node.js maintains, this means that the second someone overrides Error.prepareStackTrace, they lose the benefit of our source map handling...

first pass at fixing this...

In #29994 (closed) I proposed that we annotate call sites with the original source position, before calling Error.prepareStackTrace, as a way to provide tooling with a way to continue taking advantage of source maps... The concern was raised that we shouldn't extend the Error.prepareStackTrace further (since folks don't love this API surface).

What is this PR?

Rather than annotating the call sites passed to Error.prepareStackTrace, this PR proposes:

  1. returning Error.prepareStackTrace to its original behavior .
  2. exposing a public method for fetching source maps, source_map.findSourceMap(path[, error]), so that upstream tooling can still take advantage of source map handling, when overriding Error.prepareStackTrace.

I think this is a good approach, I'd intended on making the source map cache available to tooling eventually, and just hadn't had the time to do so... Addressing the issues in #29994 (closed), without completely removing source map support to upstream tooling, was motivation to do so.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading