Johannes Rieken
2023-12-13 17:19:09 +01:00
committed by GitHub
parent 6a289d21b5
commit 2feabcd864
@@ -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 = <any>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 {