I have code like this:
var client = new mysql.Client(options);
console.log('Icanhasclient');
client.connect(function (err) {
console.log('jannn');
active_db = client;
console.log(err);
console.log('hest');
if (callback) {
if (err) {
callback(err, null);
}
callback(null, active_db);
}
});
My problem is that Node terminates immediately when I run it. It prints 'Icanhasclient', but none of the console.log's inside the callback are called.
(mysql in this example is node-mysql.
Is there something that can be done to make node.js wait for the callback to complete before exiting?