@@ -208,32 +208,37 @@ export class WrapperProcess {
208208 this . relaunch ( )
209209 } )
210210 }
211-
212211 if ( ! this . started ) {
213- this . started = this . spawn ( ) . then ( ( child ) => {
214- // Log both to stdout and to the log directory.
215- if ( child . stdout ) {
216- child . stdout . pipe ( this . logStdoutStream )
217- child . stdout . pipe ( process . stdout )
218- }
219- if ( child . stderr ) {
220- child . stderr . pipe ( this . logStderrStream )
221- child . stderr . pipe ( process . stderr )
222- }
223- logger . debug ( `spawned inner process ${ child . pid } ` )
224- ipcMain . handshake ( child ) . then ( ( ) => {
225- child . once ( "exit" , ( code ) => {
226- logger . debug ( `inner process ${ child . pid } exited unexpectedly` )
227- ipcMain . exit ( code || 0 )
228- } )
229- } )
230- this . process = child
231- } )
212+ this . started = this . _start ( )
232213 }
233214 return this . started
234215 }
235216
236- private async spawn ( ) : Promise < cp . ChildProcess > {
217+ private async _start ( ) : Promise < void > {
218+ const child = this . spawn ( )
219+ this . process = child
220+
221+ // Log both to stdout and to the log directory.
222+ if ( child . stdout ) {
223+ child . stdout . pipe ( this . logStdoutStream )
224+ child . stdout . pipe ( process . stdout )
225+ }
226+ if ( child . stderr ) {
227+ child . stderr . pipe ( this . logStderrStream )
228+ child . stderr . pipe ( process . stderr )
229+ }
230+
231+ logger . debug ( `spawned inner process ${ child . pid } ` )
232+
233+ await ipcMain . handshake ( child )
234+
235+ child . once ( "exit" , ( code ) => {
236+ logger . debug ( `inner process ${ child . pid } exited unexpectedly` )
237+ ipcMain . exit ( code || 0 )
238+ } )
239+ }
240+
241+ private spawn ( ) : cp . ChildProcess {
237242 // Flags to pass along to the Node binary.
238243 let nodeOptions = `${ process . env . NODE_OPTIONS || "" } ${ ( this . options && this . options . nodeOptions ) || "" } `
239244 if ( ! / m a x _ o l d _ s p a c e _ s i z e = ( \d + ) / g. exec ( nodeOptions ) ) {
0 commit comments