IssueRaiser

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

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 https://github.com/microsoft/vscode/blob/32b031eeefc4fd27a21659d35070967bfe965bcc/src/vs/workbench/api/common/extensionHostMain.ts#L92 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](https://github.com/microsoft/vscode/blob/32b031eeefc4fd27a21659d35070967bfe965bcc/src/vs/workbench/a

Posted by davidanthoff on Mar 20, 2022, 1:30 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

reliability (Software)

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

davidanthoffMar 20, 2022, 1:30 AM

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 https://github.com/microsoft/vscode/blob/32b031eeefc4fd27a21659d35070967bfe965bcc/src/vs/workbench/api/common/extensionHostMain.ts#L92 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](https://github.com/microsoft/vscode/blob/32b031eeefc4fd27a21659d35070967bfe965bcc/src/vs/workbench/a

Comments (0)

No comments yet. Start the discussion.

Comment on this issue