Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit bdf7ffb

Browse files
committed
fix: don't throw MaxListenersExceeded error when more than 11 proccesses are started from sidekick
1 parent c5dd7c9 commit bdf7ffb

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Diff for: lib/before-watch.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
const { getWebpackProcesses, runWebpackCompiler, stopWebpackCompiler } = require("./compiler");
2+
let isAttachedOnEvents = false;
23

34
module.exports = function ($logger, $liveSyncService, $devicesService, hookArgs) {
45
if (hookArgs.config) {
56
const appFilesUpdaterOptions = hookArgs.config.appFilesUpdaterOptions;
67
if (appFilesUpdaterOptions.bundle) {
7-
$liveSyncService.on("liveSyncStopped", data => {
8-
const webpackProcesses = getWebpackProcesses();
9-
Object.keys(webpackProcesses).forEach(platform => {
10-
const devices = $devicesService.getDevicesForPlatform(platform);
11-
if (!devices || !devices.length) {
12-
stopWebpackCompiler(platform);
13-
}
8+
if (!isAttachedOnEvents) {
9+
$liveSyncService.on("liveSyncStopped", data => {
10+
const webpackProcesses = getWebpackProcesses();
11+
Object.keys(webpackProcesses).forEach(platform => {
12+
const devices = $devicesService.getDevicesForPlatform(platform);
13+
if (!devices || !devices.length) {
14+
stopWebpackCompiler(platform);
15+
}
16+
});
1417
});
15-
});
1618

17-
process.on("exit", () => {
18-
stopWebpackCompiler();
19-
});
19+
process.on("exit", () => {
20+
stopWebpackCompiler();
21+
});
22+
23+
isAttachedOnEvents = true;
24+
}
2025

2126
const platforms = hookArgs.config.platforms;
2227
return Promise.all(platforms.map(platform => {

0 commit comments

Comments
 (0)