@@ -71,17 +71,19 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
71
71
}
72
72
} ) ;
73
73
74
- childProcess . on ( "close" , async ( arg : any ) => {
75
- const exitCode = typeof arg === "number" ? arg : arg && arg . code ;
76
- if ( exitCode === 0 ) {
77
- resolve ( childProcess ) ;
78
- } else {
79
- const error = new Error ( `Executing webpack failed with exit code ${ exitCode } .` ) ;
80
- error . code = exitCode ;
81
- reject ( error ) ;
82
- }
74
+ childProcess . on ( "error" , ( err ) => {
75
+ this . $logger . trace ( `Unable to start webpack process in watch mode. Error is: ${ err } ` ) ;
76
+ reject ( err ) ;
77
+ } ) ;
83
78
79
+ childProcess . on ( "close" , async ( arg : any ) => {
84
80
await this . $cleanupService . removeKillProcess ( childProcess . pid . toString ( ) ) ;
81
+
82
+ const exitCode = typeof arg === "number" ? arg : arg && arg . code ;
83
+ this . $logger . trace ( `Webpack process exited with code ${ exitCode } when we expected it to be long living with watch.` ) ;
84
+ const error = new Error ( `Executing webpack failed with exit code ${ exitCode } .` ) ;
85
+ error . code = exitCode ;
86
+ reject ( error ) ;
85
87
} ) ;
86
88
} ) ;
87
89
}
@@ -94,7 +96,14 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
94
96
}
95
97
96
98
const childProcess = await this . startWebpackProcess ( platformData , projectData , prepareData ) ;
99
+ childProcess . on ( "error" , ( err ) => {
100
+ this . $logger . trace ( `Unable to start webpack process in non-watch mode. Error is: ${ err } ` ) ;
101
+ reject ( err ) ;
102
+ } ) ;
103
+
97
104
childProcess . on ( "close" , async ( arg : any ) => {
105
+ await this . $cleanupService . removeKillProcess ( childProcess . pid . toString ( ) ) ;
106
+
98
107
const exitCode = typeof arg === "number" ? arg : arg && arg . code ;
99
108
if ( exitCode === 0 ) {
100
109
resolve ( ) ;
@@ -103,8 +112,6 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
103
112
error . code = exitCode ;
104
113
reject ( error ) ;
105
114
}
106
-
107
- await this . $cleanupService . removeKillProcess ( childProcess . pid . toString ( ) ) ;
108
115
} ) ;
109
116
} ) ;
110
117
}
@@ -145,7 +152,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
145
152
}
146
153
147
154
const stdio = prepareData . watch ? [ "inherit" , "inherit" , "inherit" , "ipc" ] : "inherit" ;
148
- const childProcess = this . $childProcess . spawn ( "node" , args , { cwd : projectData . projectDir , stdio } ) ;
155
+ const childProcess = this . $childProcess . spawn ( process . execPath , args , { cwd : projectData . projectDir , stdio } ) ;
149
156
150
157
this . webpackProcesses [ platformData . platformNameLowerCase ] = childProcess ;
151
158
await this . $cleanupService . addKillProcess ( childProcess . pid . toString ( ) ) ;
0 commit comments