Skip to content

Commit bdc5eef

Browse files
author
daserge
committed
Avoiding "write EPIPE process.send" error on exit
1 parent 52690ed commit bdc5eef

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/vs/workbench/node/extensionHostProcess.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface IRendererConnection {
1616
initData: IInitData;
1717
}
1818

19+
var _isTerminating;
1920
// This calls exit directly in case the initialization is not finished and we need to exit
2021
// Otherwise, if initialization completed we go to extensionHostMain.terminate()
2122
let onTerminate = function () {
@@ -32,6 +33,11 @@ function connectToRenderer(): TPromise<IRendererConnection> {
3233
let msg = marshalling.parse(raw);
3334

3435
const remoteCom = createIPC(data => {
36+
// Needed to avoid EPIPE errors in process.send below when a channel is closed
37+
if (_isTerminating === true) {
38+
return;
39+
}
40+
3541
process.send(data);
3642
stats.push(data.length);
3743
});
@@ -40,6 +46,7 @@ function connectToRenderer(): TPromise<IRendererConnection> {
4046
process.on('message', (msg) => {
4147
if (msg.type === '__$terminate') {
4248
onTerminate();
49+
_isTerminating = true;
4350
return;
4451
}
4552
remoteCom.handle(msg);

0 commit comments

Comments
 (0)