@parcel/workers 2.8.1 → 2.8.3

Sign up to get free protection for your applications and to get access to all the features.
package/lib/Worker.js CHANGED
@@ -61,8 +61,9 @@ class Worker extends _events().default {
61
61
 
62
62
  for (let i = 0; i < filteredArgs.length; i++) {
63
63
  let arg = filteredArgs[i];
64
+ let isArgWithParam = (arg === '-r' || arg === '--require') && filteredArgs[i + 1] === '@parcel/register' || arg === '--title';
64
65
 
65
- if ((arg === '-r' || arg === '--require') && filteredArgs[i + 1] === '@parcel/register') {
66
+ if (isArgWithParam) {
66
67
  filteredArgs.splice(i, 2);
67
68
  i--;
68
69
  }
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.1",
3
+ "version": "2.8.3",
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.1",
25
- "@parcel/logger": "2.8.1",
26
- "@parcel/types": "2.8.1",
27
- "@parcel/utils": "2.8.1",
24
+ "@parcel/diagnostic": "2.8.3",
25
+ "@parcel/logger": "2.8.3",
26
+ "@parcel/types": "2.8.3",
27
+ "@parcel/utils": "2.8.3",
28
28
  "chrome-trace-event": "^1.0.2",
29
29
  "nullthrows": "^1.1.1"
30
30
  },
31
31
  "peerDependencies": {
32
- "@parcel/core": "^2.8.1"
32
+ "@parcel/core": "^2.8.3"
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": "f8d3fc30ca5b33d8f8674525f2a741d662c5986a"
39
+ "gitHead": "349a6caf40ec8abb6a49fcae0765f8f8deb2073d"
40
40
  }
package/src/Worker.js CHANGED
@@ -53,10 +53,11 @@ export default class Worker extends EventEmitter {
53
53
 
54
54
  for (let i = 0; i < filteredArgs.length; i++) {
55
55
  let arg = filteredArgs[i];
56
- if (
57
- (arg === '-r' || arg === '--require') &&
58
- filteredArgs[i + 1] === '@parcel/register'
59
- ) {
56
+ let isArgWithParam =
57
+ ((arg === '-r' || arg === '--require') &&
58
+ filteredArgs[i + 1] === '@parcel/register') ||
59
+ arg === '--title';
60
+ if (isArgWithParam) {
60
61
  filteredArgs.splice(i, 2);
61
62
  i--;
62
63
  }
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