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

change .on to .once, remove possible memory leaks #2420

Merged
merged 1 commit into from Oct 17, 2016

Conversation

duereg
Copy link
Contributor

@duereg duereg commented Oct 14, 2016

In doing stress testing on my application, started seeing these messages in my logs:

(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 Request.onRequestResponse (...node_modules/request/request.js:896:14)
    at emitOne (events.js:82:20)
    at ClientRequest.emit (events.js:169:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:433:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)
    at Socket.socketOnData (_http_client.js:322:20)
(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 Request.onRequestResponse (.../node_modules/request/request.js:968:21)
    at emitOne (events.js:82:20)
    at ClientRequest.emit (events.js:169:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:433:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)
    at Socket.socketOnData (_http_client.js:322:20)
    at emitOne (events.js:77:13)

@mikeal
Copy link
Member

mikeal commented Oct 17, 2016

Why is this function being called multiple times on the same request instance?

I'm +1 on using .once() whenever possible, so I'm +1 on this PR, but I am worried that there's another bug here that is calling this more times than it should.

@duereg
Copy link
Contributor Author

duereg commented Oct 17, 2016

@mikeal What you're saying makes sense... but I don't know the overall codebase for this well enough to diagnose. Sorry I can't be more helpful here.

@mikeal mikeal merged commit cb8c1f6 into request:master Oct 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants