rogeliog / jest-runner-mocha

A Mocha runner for Jest
70 stars 12 forks source link

EventEmitter memory leak #21

Open jehy opened 4 years ago

jehy commented 4 years ago

I have a big project with 5000+ tests, and I receive warning:

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 501 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit

The problem lies within node_modules/jest-runner-mocha/build/runMocha.js

  mocha.addFile(testPath);
  var onEnd = function onEnd() {
    process.on('exit', function () {
      return process.exit();
    });
  };

Without babel, it looks like

  const onEnd = () => {
    process.on('exit', () => process.exit());
  };

Seems like an exit listener is being added for every test file. It looks very suspicious and can possibly be a memory leak too.

Also, I don't understand the meaning of this - exiting in exit does not make sense to me...