Skip to content

Commit f0e79b3

Browse files
fix: webpackCompilerService should not cache childProcesses forever
Currently the webpackCompilerService caches the started webpack processes, but it removes them from the cache only when someone calls `stopWebpackCompiler` method. This is a major problem as we cache the first instance of the child process and we do not remove it, even when the process dies. For example, when you run just build, we start the webpack process without watch mode, the webpackCompilerService caches the child process, it exits, but the instance remains cached. Trying to run the application on device does not start new webpack process and different failures occur.
1 parent b7595b5 commit f0e79b3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/services/webpack/webpack-compiler-service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
7272

7373
childProcess.on("error", (err) => {
7474
this.$logger.trace(`Unable to start webpack process in watch mode. Error is: ${err}`);
75+
delete this.webpackProcesses[platformData.platformNameLowerCase];
7576
reject(err);
7677
});
7778

@@ -82,6 +83,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
8283
this.$logger.trace(`Webpack process exited with code ${exitCode} when we expected it to be long living with watch.`);
8384
const error = new Error(`Executing webpack failed with exit code ${exitCode}.`);
8485
error.code = exitCode;
86+
delete this.webpackProcesses[platformData.platformNameLowerCase];
8587
reject(error);
8688
});
8789
});
@@ -97,12 +99,14 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
9799
const childProcess = await this.startWebpackProcess(platformData, projectData, prepareData);
98100
childProcess.on("error", (err) => {
99101
this.$logger.trace(`Unable to start webpack process in non-watch mode. Error is: ${err}`);
102+
delete this.webpackProcesses[platformData.platformNameLowerCase];
100103
reject(err);
101104
});
102105

103106
childProcess.on("close", async (arg: any) => {
104107
await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
105108

109+
delete this.webpackProcesses[platformData.platformNameLowerCase];
106110
const exitCode = typeof arg === "number" ? arg : arg && arg.code;
107111
if (exitCode === 0) {
108112
resolve();

0 commit comments

Comments
 (0)