Skip to content

v8 error taming should leverage prepareStackTrace #1798

Open

Description

@mhofman

What is the Problem Being Solved?

Error.prepareStackTrace can be used by Node.js to apply source maps to the captured stack trace. However SES sets its own prepareStackTrace during v8 Error taming. Instead of completely discarding it. Maybe instead it should leverage as much as possible the existing prepareStackTrace to prepare its own stack strings?

Furthermore, if the start compartment set a prepareStackTrace after lockdown, it seems the returned value will be used for the .stack property instead of the empty string, even if errorTaming is set to 'safe':

prepareStackTrace(error, sst) {
weakmapSet(stackInfos, error, { callSites: sst });
return inputPrepareFn(error, safeV8SST(sst));
},

Description of the Design

Use the original prepareStackTrace to generate the stack string.

Alternatively implement source map support in endo itself (maybe once part of the error handling logic has been ejected from SES as a trusted shim?, see #945). While node's prepareStackTrace implementation is not very modular, it should be possible to rebuild it on top of findSourceMap.

Security Considerations

None particularly. The start compartment is already in position to decide how lockdown should tame errors, and can also set prepareStackTrace after lockdown

Scaling Considerations

None

Test Plan

load some minified source which throws errors in Node.js with --use-source-maps and verify stack traces are mapped.

Upgrade Considerations

None particular

Activity

  1. self-assigned this
    on Oct 6, 2023
  2. added
    kriskowal-review-2024-01Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024
    on Jan 6, 2024
  3. removed
    kriskowal-review-2024-01Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024
    on Jan 31, 2024
  4. self-assigned this
    on Jul 12, 2024
  5. erights commented on Jul 12, 2024

    @erights
    Contributor

    Hi @mhofman , I've co-assigned myself to this.

  6. mhofman commented on Jul 12, 2024

    @mhofman
    ContributorAuthor

    Use the original prepareStackTrace to generate the stack string.

    I believe I explored this, and that didn't work

  7. added a commit that references this issue on Jul 16, 2024
  8. mhofman commented on Sep 15, 2025

    @mhofman
    ContributorAuthor

    It looks like since I filed this issue, Node.js actually decided to expose their internal prepareStackTrace, which should make this very straightforward.

  9. erights commented on Sep 16, 2025

    @erights
    Contributor

    Huh. Testing just now, it was added sometime between Node v18.19.0 exclusive and Node v20.18.3 inclusive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions