Skip to content

Commit b10c51b

Browse files
committed
Merge pull request microsoft#13774 from daserge:epipe-process-send
Avoiding "write EPIPE process.send" error on exit
2 parents 10fe85a + bdc5eef commit b10c51b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/vs/workbench/node/extensionHostProcess.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ interface IRendererConnection {
1717
initData: IInitData;
1818
}
1919

20+
/**
21+
* Flag set when in shutdown phase to avoid communicating to the main process.
22+
*/
23+
let isTerminating = false;
24+
2025
// This calls exit directly in case the initialization is not finished and we need to exit
2126
// Otherwise, if initialization completed we go to extensionHostMain.terminate()
2227
let onTerminate = function () {
@@ -36,13 +41,18 @@ function connectToRenderer(): TPromise<IRendererConnection> {
3641
let msg = marshalling.parse(raw);
3742

3843
const remoteCom = createIPC(data => {
44+
// Needed to avoid EPIPE errors in process.send below when a channel is closed
45+
if (isTerminating === true) {
46+
return;
47+
}
3948
queuedSender.send(data);
4049
stats.push(data.length);
4150
});
4251

4352
// Listen to all other messages
4453
process.on('message', (msg) => {
4554
if (msg.type === '__$terminate') {
55+
isTerminating = true;
4656
onTerminate();
4757
return;
4858
}

0 commit comments

Comments
 (0)