@parcel/workers 2.8.0 → 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/WorkerFarm.js CHANGED
@@ -136,7 +136,16 @@ class WorkerFarm extends _events().default {
136
136
 
137
137
  this.localWorker = require(this.options.workerPath);
138
138
  this.localWorkerInit = this.localWorker.childInit != null ? this.localWorker.childInit() : null;
139
- this.run = this.createHandle('run');
139
+ this.run = this.createHandle('run'); // Worker thread stdout is by default piped into the process stdout, if there are enough worker
140
+ // threads to exceed the default listener limit, then anything else piping into stdout will trigger
141
+ // the `MaxListenersExceededWarning`, so we should ensure the max listeners is at least equal to the
142
+ // number of workers + 1 for the main thread.
143
+ //
144
+ // Note this can't be fixed easily where other things pipe into stdout - even after starting > 10 worker
145
+ // threads `process.stdout.getMaxListeners()` will still return 10, however adding another pipe into `stdout`
146
+ // will give the warning with `<worker count + 1>` as the number of listeners.
147
+
148
+ process.stdout.setMaxListeners(Math.max(process.stdout.getMaxListeners(), WorkerFarm.getNumWorkers() + 1));
140
149
  this.startMaxWorkers();
141
150
  }
142
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/workers",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -21,20 +21,20 @@
21
21
  "node": ">= 12.0.0"
22
22
  },
23
23
  "dependencies": {
24
- "@parcel/diagnostic": "2.8.0",
25
- "@parcel/logger": "2.8.0",
26
- "@parcel/types": "2.8.0",
27
- "@parcel/utils": "2.8.0",
24
+ "@parcel/diagnostic": "2.8.2",
25
+ "@parcel/logger": "2.8.2",
26
+ "@parcel/types": "2.8.2",
27
+ "@parcel/utils": "2.8.2",
28
28
  "chrome-trace-event": "^1.0.2",
29
29
  "nullthrows": "^1.1.1"
30
30
  },
31
31
  "peerDependencies": {
32
- "@parcel/core": "^2.8.0"
32
+ "@parcel/core": "^2.8.2"
33
33
  },
34
34
  "browser": {
35
35
  "./src/cpuCount.js": false,
36
36
  "./src/process/ProcessWorker.js": false,
37
37
  "./src/threads/ThreadsWorker.js": false
38
38
  },
39
- "gitHead": "c3bbe0a6160186f496ca2f9e9bead9376c0522f1"
39
+ "gitHead": "3437f64e4c6f57d911614c480b742e229149f200"
40
40
  }
package/src/WorkerFarm.js CHANGED
@@ -101,6 +101,21 @@ export default class WorkerFarm extends EventEmitter {
101
101
  this.localWorker.childInit != null ? this.localWorker.childInit() : null;
102
102
  this.run = this.createHandle('run');
103
103
 
104
+ // Worker thread stdout is by default piped into the process stdout, if there are enough worker
105
+ // threads to exceed the default listener limit, then anything else piping into stdout will trigger
106
+ // the `MaxListenersExceededWarning`, so we should ensure the max listeners is at least equal to the
107
+ // number of workers + 1 for the main thread.
108
+ //
109
+ // Note this can't be fixed easily where other things pipe into stdout - even after starting > 10 worker
110
+ // threads `process.stdout.getMaxListeners()` will still return 10, however adding another pipe into `stdout`
111
+ // will give the warning with `<worker count + 1>` as the number of listeners.
112
+ process.stdout.setMaxListeners(
113
+ Math.max(
114
+ process.stdout.getMaxListeners(),
115
+ WorkerFarm.getNumWorkers() + 1,
116
+ ),
117
+ );
118
+
104
119
  this.startMaxWorkers();
105
120
  }
106
121