Skip to content

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 lookup listeners added to [Socket] #176

@pjonsson

Description

@pjonsson

My logs TerriaMap 0.2.4 logs contain quite a few warnings about:

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 lookup listeners added to [Socket]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit

and I also get the same warning but for [TLSSocket]. I don't think this is something that was introduced recently, I also got the warnings with TerriaMap 0.2.2.

Here is a warning but with --trace-warnings enabled:

(node:1) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 lookup listeners added to [Socket]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at _addListener (node:events:598:17)
    at Socket.addListener (node:events:616:10)
    at Readable.on (node:internal/streams/readable:1128:35)
    at Socket.once (node:events:660:8)
    at Request.<anonymous> (/app/node_modules/terriajs-server/lib/controllers/proxy.js:266:32)
    at Request.emit (node:events:524:28)
    at ClientRequest.<anonymous> (/app/node_modules/request/request.js:858:10)
    at ClientRequest.emit (node:events:524:28)
    at tickOnSocket (node:_http_client:857:7)
    at onSocketNT (node:_http_client:920:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:91:21)

I had a look in the code and it looks like it's the line with socket.once('lookup', ..) that causes the warning, but from my reading it seems that once() event listeners are removed when triggered, so perhaps this is one of the uncommon cases where it's not a leak and the limit should be increased?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions