Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

EventEmitter leak detection #143

@isaacs

Description

@isaacs
(node) warning: possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at TLSSocket.addListener (events.js:239:17)
    at TLSSocket.Readable.on (_stream_readable.js:680:33)
    at Request.<anonymous> (/Users/isaacs/dev/npm/npm/node_modules/npm-registry-client/lib/request.js:153:7)
    at emitOne (events.js:77:13)
    at Request.emit (events.js:169:7)
    at ClientRequest.<anonymous> (/Users/isaacs/dev/npm/npm/node_modules/request/request.js:791:10)
    at emitOne (events.js:82:20)
    at ClientRequest.emit (events.js:169:7)
    at tickOnSocket (_http_client.js:523:7)
    at onSocketNT (_http_client.js:535:5)

This is happening at this line in lib/request.js:

  req.on('error', cb)
  req.on('socket', function (s) {
    s.on('error', cb)
  })

Because requests re-use those connections, you can end up attaching the error handler a lot of times.

It'd be good to remove it or something once we're done.

Apologies, this would be a PR instead of an issue but I didn't have time to dig in and figure out the best place to do that. Posting it this way so that it's not lost, like tears in rain.

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