I've read a bunch on this topic, but still don't understand the issue with my code (or the problem with my logic/understanding of what's actually going on). Can someone please explain what I'm missing?
Basically, I've narrowed this problem down to when I run the following HTTP GET request a bunch of times in a row. If I only run the loop 10 times, it's fine, but 100 times, the error gets thrown.
Here's my code:
var request = require('request');
for(var i = 0; i < 100; i++){
request({
url:'http://www.govtrack.us/api/v2/vote',
qs:{
related_bill : 292931
}
}, function(err, res, body){
//console.log(res);
console.log(err);
//console.log(body);
});
}
Here's the error:
node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Socket.EventEmitter.addListener (events.js:160:15)
at Socket.Readable.on (_stream_readable.js:689:33)
at Socket.EventEmitter.once (events.js:179:8)
at Request.onResponse (/Users/Josh/Node/Dev/node_modules/request/request.js:625:25)
at ClientRequest.g (events.js:175:14)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1689:21)
at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:120:23)
at Socket.socketOnData [as ondata] (http.js:1584:20)
at TCP.onread (net.js:525:27)