Fixes #32990: Call our own version of exit which does not wait for a debugger to disconnect (on the extension host)

This commit is contained in:
Alex Dima 2017-08-25 16:30:22 +02:00
parent 9de3068a4d
commit e60ab23372
4 changed files with 27 additions and 7 deletions

6
npm-shrinkwrap.json generated
View file

@ -296,9 +296,9 @@
"resolved": "https://registry.npmjs.org/native-keymap/-/native-keymap-1.2.5.tgz"
},
"native-watchdog": {
"version": "0.2.0",
"from": "native-watchdog@0.2.0",
"resolved": "https://registry.npmjs.org/native-watchdog/-/native-watchdog-0.2.0.tgz"
"version": "0.3.0",
"from": "native-watchdog@0.3.0",
"resolved": "https://registry.npmjs.org/native-watchdog/-/native-watchdog-0.3.0.tgz"
},
"node-pty": {
"version": "0.7.0",

View file

@ -35,7 +35,7 @@
"keytar": "^4.0.3",
"minimist": "1.2.0",
"native-keymap": "1.2.5",
"native-watchdog": "0.2.0",
"native-watchdog": "0.3.0",
"node-pty": "0.7.0",
"nsfw": "1.0.16",
"semver": "4.3.6",

View file

@ -7,4 +7,6 @@ declare module 'native-watchdog' {
export function start(timeout: number): void;
export function exit(exitCode: number): void;
}

View file

@ -17,15 +17,33 @@ import { QueryType, ISearchQuery } from 'vs/platform/search/common/search';
import { DiskSearch } from 'vs/workbench/services/search/node/searchService';
import { IInitData, IEnvironment, IWorkspaceData, MainContext } from 'vs/workbench/api/node/extHost.protocol';
import * as errors from 'vs/base/common/errors';
// import * as watchdog from 'native-watchdog';
import * as watchdog from 'native-watchdog';
const nativeExit = process.exit.bind(process);
// const nativeExit = process.exit.bind(process);
process.exit = function () {
const err = new Error('An extension called process.exit() and this was prevented.');
console.warn(err.stack);
};
export function exit(code?: number) {
nativeExit(code);
//nativeExit(code);
// TODO@electron
// See https://github.com/Microsoft/vscode/issues/32990
// calling process.exit() does not exit the process when the process is being debugged
// It waits for the debugger to disconnect, but in our version, the debugger does not
// receive an event that the process desires to exit such that it can disconnect.
// Do exactly what node.js would have done, minus the wait for the debugger part
if (code || code === 0) {
process.exitCode = code;
}
if (!(<any>process)._exiting) {
(<any>process)._exiting = true;
process.emit('exit', process.exitCode || 0);
}
watchdog.exit(process.exitCode || 0);
}
interface ITestRunner {