Ensure maxListeners for process.stdout accounts for workers #8689
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
↪️ Pull Request
Fixes the
MaxListenersExceededWarning
warnings that would occur in environments with > 10 workers.This occurs because by default Node will pipe worker stdout to process stdout, however it doesn't increase the
maxListener
property of theprocess.stdout
event emitter.This behaviour was validated with a simple test script - added 20 workers and
process.stdout.getMaxListeners()
was still10
, piping tostdout
resulted in a warning about 21 listeners.The "Ora" library used by the CLI Reporter also pipes into
process.stdout
, and when this pipe is connected this triggers the warnings asworker_count + 1 > 10
(which is the default maxListener value).As a fix we will set the
process.stdout.setMaxListeners()
to equal to the worker count + 1. This isn't perfect, especially if something else hooks intoprocess.stdout
in future, but due to the limitation of callingprocess.stdout.getMaxListeners()
mentioned above is at least a better outcome for Parcel out of the box.Related in the context of Parcel: sindresorhus/ora#162
🚨 Test instructions
Before the patch - run Parcel with:
After the patch the same command does not trigger any warnings.
✔️ PR Todo