On Thu, Apr 5, 2012 at 15:48, Paul Selden <[email protected]> wrote: > I'm using: https://github.com/mikeal/request/blob/master/forever.js as an > agent in a project that uses a service-oriented-architecture (currently over > HTTP) in order to maximize the chance that the connections are kept alive > (note, I'm not using the entire request module, just that agent). > > ...<snip>.... > options.agent = new ForeverAgent({ minSockets: 100, maxSockets: 100}); > var req = http.request(options, function (res) { > ...<snip>... > }); > > req.setTimeout(timeout, function(){ req.abort(); }); > > As more calls are made, it seems to "accumulate" the timeouts for the > underlying socket as it is being re-used and I eventually get this error: > > [2012-04-05 09:21:07.144] [ERROR] console - (node) warning: possible > EventEmitter memory leak detected. 11 listeners added. Use > emitter.setMaxListeners() to increase limit. > [2012-04-05 09:21:07.146] [ERROR] console - Trace: > at Socket.<anonymous> (events.js:139:15) > at Socket.once (events.js:160:8) > at Socket.setTimeout (net.js:143:12) > at ClientRequest.<anonymous> (http.js:1287:29) > at ClientRequest.g (events.js:156:14) > at ClientRequest.emit (events.js:88:20) > at Array.0 (http.js:1273:9) > at EventEmitter._tickCallback (node.js:192:40) > > Is this a bug with the forever agent, the http module, or something that I > need to unbind myself after a request is finished?
It's documented so it's not a bug. :-) When you add a callback, it gets registered as a listener for the 'timeout' event with EventEmitter.prototype.once(). If you keep registering listeners, you'll hit the max listeners limit. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
