Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxListenersExceededWarning: Possible EventEmitter memory leak detected #72

Open
jeanmatthieud opened this issue Jun 10, 2022 · 4 comments

Comments

@jeanmatthieud
Copy link

I running IPX with npx ipx and some env vars.

I'm getting a lot of warnings in production:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit

@jeanmatthieud
Copy link
Author

I created a custom node script to start IPX, and increased the limit to "50".
I'm still having the issue, with "51" close listeners.

@pi0
Copy link
Member

pi0 commented Jun 20, 2022

Hi. Do you mind providing a reproduction? 🙏🏼

@jeanmatthieud
Copy link
Author

At first, I was using npx ipx and saw the issue as reported in the issue.

Then, I created a little script, based on cli.ts:

import consola from 'consola'
import { listen } from 'listhen'
import { createIPX, createIPXMiddleware } from 'ipx'
import { EventEmitter } from 'events';

// Added line
EventEmitter.defaultMaxListeners = 50;

async function main() {
  const ipx = createIPX({})
  const middleware = createIPXMiddleware(ipx)
  await listen(middleware, {
    clipboard: false
  })
}

main().catch((err) => {
  consola.error(err)
  process.exit(1)
})

But I'm still getting the issue, with between 20 and 200 requests per minute.
All images are stored online, and requested through HTTPS.
They are already compressed (JPG 80%) and limited to 1920px per side (so they are not heavy images).

I'm using node 16 and npm 8.5.0.

@kyr1eee
Copy link

kyr1eee commented Jul 26, 2022

Me too. And I set the evetemitter's maxListeners to zero.
here the code: require('events').EventEmitter.defaultMaxListeners = 0

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

No branches or pull requests

3 participants