Skip to content

Use source maps if extension ships one for error stack trace formatting #145473

@davidanthoff

Description

@davidanthoff

In the Julia extension we have crash reporting setup, so that we send a crash report whenever an exception occurs in our extension. We also bundle our extension with webpack. One problem is that the stack traces in the exceptions (if something goes wrong) are essentially useless, as they refer to locations in the bundled version of the extension, i.e. everything on line 1 :) We do actually ship a source map file in the extension, but the information in there doesn't show up in the exception objects.

I think there are broadly speaking two ways to improve the situation: 1) run the extension host with the --enable-source-maps flag (but note that any custom Error.prepareStackTrace handler is then disabled, or 2) modify the already existing Error.prepareStackTrace handler in the extension host

(<any>Error).prepareStackTrace = (error: Error, stackTrace: errors.V8CallSite[]) => {
to apply source map information if it is there.

I am experimenting with that at the moment by using the https://www.npmjs.com/package/source-map-support package in our extension. That actually does lead to error objects that have stack traces that use the source map information, so that is great. The drawback, though, is that by using this package I think we are overriding the default VS Code Error.prepareStackTrace handler that gets set here, and potentially even for not just our extension? That seems really bad, but at the moment I don't really have a better idea on how to handle that...

I think the ideal situation is that the default Error.prepareStackTrace that the VS Code extension hosts installs essentially provides the same functionality that the source-map-support package provides.

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-hostExtension host issuesfeature-requestRequest for new features or functionality

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions