diff --git a/src/vs/workbench/node/extensionHostProcess.ts b/src/vs/workbench/node/extensionHostProcess.ts index 6551b3f97046a65029f8f5d686c36d8652eac4db..e33e1cc82d72f00eb6f8515f14a23e411eac52fd 100644 --- a/src/vs/workbench/node/extensionHostProcess.ts +++ b/src/vs/workbench/node/extensionHostProcess.ts @@ -17,6 +17,11 @@ interface IRendererConnection { initData: IInitData; } +/** + * Flag set when in shutdown phase to avoid communicating to the main process. + */ +let isTerminating = false; + // This calls exit directly in case the initialization is not finished and we need to exit // Otherwise, if initialization completed we go to extensionHostMain.terminate() let onTerminate = function () { @@ -36,6 +41,10 @@ function connectToRenderer(): TPromise { let msg = marshalling.parse(raw); const remoteCom = createIPC(data => { + // Needed to avoid EPIPE errors in process.send below when a channel is closed + if (isTerminating === true) { + return; + } queuedSender.send(data); stats.push(data.length); }); @@ -43,6 +52,7 @@ function connectToRenderer(): TPromise { // Listen to all other messages process.on('message', (msg) => { if (msg.type === '__$terminate') { + isTerminating = true; onTerminate(); return; }