I have tried for a long time to solve this problem on my own but can't find a suitable fix for my problem.
I have this method:
handle_database = function(callback, req, res) {
pool.getConnection(function(err,connection){
if (err) {
res.json({"code" : 100, "status" : "Error in connection database"});
return;
}
connection.query("select * from `atable`",function(err,rows){
connection.release();
if(!err) {
callback(rows);
}
});
connection.on('error', function(err) {
res.json({"code" : 100, "status" : "Error in connection database"});
return;
});
});
}
This method is used in my routes.js in this way:
router.get('/', function(req, res){
db.getUsers(function (data) {
res.render('pages/index',{users: data, title: 'title'});
}, req, res);
});
When I refresh this page 11 times in a row I get the following warning:
(node:11780) Warning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
But I cannot find how to fix this, or is just setting the limit to 0 a smart idea?
var pool = mysql.createPool({ connectionLimit : 10, host : 'localhost', user : 'root', password : 'pw', database : 'db', debug: false, });- R4LPH