-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use source maps if extension ships one for error stack trace formatting #145473
Use source maps if extension ships one for error stack trace formatting #145473
Comments
A little help here: fullstack-build/tslog#205 (comment)
By the way how to add that argument According to the official documentation, I think the executable This issue says the extension host is running as Node.js but how to configure its command line? If via microsoft/vscode-discussions#1347 microsoft/vscode-js-debug#2010 Code for wrapping extension host console methods: this._wrapConsoleMethod('info', 'log');
this._wrapConsoleMethod('log', 'log');
this._wrapConsoleMethod('warn', 'warn');
this._wrapConsoleMethod('debug', 'debug');
this._wrapConsoleMethod('error', 'error'); Code for running extension process: const serviceName = `${this.configuration.type}-${this.id}`;
const modulePath = FileAccess.asFileUri('bootstrap-fork.js').fsPath;
const args = this.configuration.args ?? [];
const execArgv = this.configuration.execArgv ?? [];
const allowLoadingUnsignedLibraries = this.configuration.allowLoadingUnsignedLibraries;
const respondToAuthRequestsFromMainProcess = this.configuration.respondToAuthRequestsFromMainProcess;
const stdio = 'pipe';
const env = this.createEnv(configuration);
this.log('creating new...', Severity.Info);
// Fork utility process
this.process = utilityProcess.fork(modulePath, args, {
serviceName,
env,
execArgv,
allowLoadingUnsignedLibraries,
respondToAuthRequestsFromMainProcess,
stdio
}); According to this article, a faulty debugger seems to be blamed. You could try the Chrome Javascript debugger for Node.js, and the source map support is added automatically. To resolve the incorrect Also if the official Electron build does not comply with the need of most VSCode users, Microsoft could build a custom version of Electron with more Node.js command line flags, or just discard every such restriction for convenience. I think I have found where to specify the After a few trials, I can confirm that setting One can verify if it is working by calling Even though I have patched the original Electron binary and got more Before patching: After patching: |
Now it is called After compilation, two files will contain the same parts modifying
By restoring original In this case, we could have three optuons:
I have a hackish solution that could solve the problem once and for all. This requires According to the source code above, |
Fixes the source map support issue in vscode extension development error stacktrace Refs microsoft#145473 (comment)
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 customError.prepareStackTrace
handler is then disabled, or 2) modify the already existingError.prepareStackTrace
handler in the extension hostvscode/src/vs/workbench/api/common/extensionHostMain.ts
Line 92 in 32b031e
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 thesource-map-support
package provides.The text was updated successfully, but these errors were encountered: