Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

MaxListenersExceededWarning: Possible EventEmitter memory leak detected #63

Closed
djones opened this issue May 9, 2019 · 2 comments
Closed

Comments

@djones
Copy link

djones commented May 9, 2019

I've recently been hitting this error when running tests for our Oclif CLI:

(node:29441) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:280:19)
    at WriteStream.addListener (events.js:297:10)
    at WriteStream.Readable.on (_stream_readable.js:772:35)
    at Snapshot._swallowEPIPE (/Users/djones/Code/percy-agent/node_modules/@oclif/command/lib/command.js:133:24)
    at Snapshot.init (/Users/djones/Code/percy-agent/node_modules/@oclif/command/lib/command.js:67:14)
    at Snapshot._run (/Users/djones/Code/percy-agent/node_modules/@oclif/command/lib/command.js:33:24)
    at Function.Command.run (/Users/djones/Code/percy-agent/node_modules/@oclif/command/lib/command.js:155:16)
    at <anonymous>

After a wee bit of googling I noticed the Heroku CLI has actually been getting the same warnings recently: https://ci.appveyor.com/project/heroku/heroku-cli-command/branch/master#L174

and I found this for the Force.com CLI: forcedotcom/cli#30

Fairly sure it was #54 that has introduced this bug, so I downgraded to @oclif/command 1.5.10 (from 1.5.12) and it has fixed the issue.

I think the problem is that here:

protected _swallowEPIPE() {
  process.stdout.on('error', err => {
    if (err && err.code === 'EPIPE') return
    throw err
  })
}

we turn on process.stdout.on but it is never closed so the listeners pile up.

@tnoonan-salesforce
Copy link
Contributor

tnoonan-salesforce commented May 30, 2019

@djones I put up a PR to fix this issue.
#65

@tnoonan-salesforce
Copy link
Contributor

#65

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants