diff --git a/src/vs/workbench/api/node/extensionHostProcess.ts b/src/vs/workbench/api/node/extensionHostProcess.ts index bb3cbfbca7b..785db7edd43 100644 --- a/src/vs/workbench/api/node/extensionHostProcess.ts +++ b/src/vs/workbench/api/node/extensionHostProcess.ts @@ -76,6 +76,7 @@ const args = minimist(process.argv.slice(2), { // custom process.exit logic... const nativeExit: IExitFn = process.exit.bind(process); +const nativeOn = process.on.bind(process); function patchProcess(allowExit: boolean) { process.exit = function (code?: number) { if (allowExit) { @@ -97,6 +98,23 @@ function patchProcess(allowExit: boolean) { // on the desktop. // Refs https://github.com/microsoft/vscode/issues/151012#issuecomment-1156593228 process.env['ELECTRON_RUN_AS_NODE'] = '1'; + + process.on = function (event: string, listener: (...args: any[]) => void) { + if (event === 'uncaughtException') { + listener = function () { + try { + return listener.call(undefined, arguments); + } catch { + // DO NOT HANDLE NOR PRINT the error here because this can and will lead to + // more errors which will cause error handling to be reentrant and eventually + // overflowing the stack. Do not be sad, we do handle and annotate uncaught + // errors properly in 'extensionHostMain' + } + }; + } + nativeOn(event, listener); + }; + } interface IRendererConnection {