File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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()
2227let 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 }
You can’t perform that action at this time.
0 commit comments