I'm developing a node.js app that displays a single page with map data (which will eventually be updated using an .ajax call).
Right now, my code looks like this:
app.get('/', function(req, res) {
postgres.retrieve('SELECT * FROM settings', function(err, proj_data){
if (err){
res.send(500);
}
else{
postgres.retrieve('SELECT * FROM report ORDER BY ordering', function(err, report_data){
res.render('map', {project: proj_data[0], report: report_data});
});
}
});
and postgres.retrieve is a function that uses the node-postgres client:
retrieve: function(query, complete){
pg.connect(connection, function(err, client, done){
client.query(query, function(err, results){
if (err){
done();
return complete(err, null);
}
else {
done();
return complete(null, results.rows);
}
});
});
},
Currently, if I hit f5 10 times (over, say, 10 seconds), everything seems to respond fine, but right after, memory usage goes way up and the app becomes totally unresponsive. I'm wondering if there's something in my code that's causing this problem.
Thanks!