Commit 593c2bc 1 parent ed1e231 commit 593c2bc Copy full SHA for 593c2bc
File tree 1 file changed +15
-0
lines changed
packages/core/workers/src
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -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
You can’t perform that action at this time.
0 commit comments