Skip to content

Commit

Permalink
Fixes #32990: Call our own version of exit which does not wait for a …
Browse files Browse the repository at this point in the history
…debugger to disconnect (on the extension host)
  • Loading branch information
alexdima committed Aug 25, 2017
1 parent 9de3068 commit e60ab23
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
6 changes: 3 additions & 3 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/typings/native-watchdog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ declare module 'native-watchdog' {

export function start(timeout: number): void;

export function exit(exitCode: number): void;

}
24 changes: 21 additions & 3 deletions src/vs/workbench/node/extensionHostMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e60ab23

Please sign in to comment.