change .on to .once, prevent possible memory leaks #1084

Merged
merged 1 commit into from Oct 14, 2016

Conversation

Projects
None yet
2 participants
@duereg
Contributor

duereg commented Oct 14, 2016

recorded multiple memory leaks from superagent. This was from a 1.1 version, but the underlying problem was still the same.

(node) warning: possible EventEmitter memory leak detected. 11 end listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at IncomingMessage.addListener (events.js:239:17)
    at IncomingMessage.Readable.on (_stream_readable.js:680:33)
    at ClientRequest.<anonymous> (.../node_modules/superagent/lib/node/index.js:915:9)
at IncomingMessage.Readable.on (_stream_readable.js:680:33)
    at IncomingMessage.once (events.js:265:8)
    at IncomingMessage.Readable.pipe (_stream_readable.js:486:9)
    at Object.exports.unzip (.../node_modules/superagent/lib/node/utils.js:90:7)
    at ClientRequest.<anonymous> (.../node_modules/superagent/lib/node/index.js:825:13)
at IncomingMessage.addListener (events.js:239:17)
    at IncomingMessage.Readable.on (_stream_readable.js:680:33)
    at parseJSON (.../node_modules/superagent/lib/node/parsers/json.js:6:7)
    at ClientRequest.<anonymous> (.../node_modules/superagent/lib/node/index.js:883:9)
    at emitOne (events.js:82:20)
    at ClientRequest.emit (events.js:169:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:433:21)
@kornelski

This comment has been minimized.

Show comment
Hide comment
@kornelski

kornelski Oct 14, 2016

Collaborator

Nice catch. Thanks!

Collaborator

kornelski commented Oct 14, 2016

Nice catch. Thanks!

@kornelski kornelski merged commit a73dfab into visionmedia:master Oct 14, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment