I am currently developing an API using node.js and MySQL. I am new to this non-blocking material and I have a question. I am using node and the MySQL module.
Let's say that we have such a function:
function doQuery(sql, callback) {
connect();
client.query(sql, function(err, results, fields) {
if (err) {
errorLog.trace(err, __filename);
throw err;
} else {
logger.trace('DATABASE ACCESS: {query: ' + sql + '} result: OK', __filename);
}
client.end();
callback(results);
});
}
Everything works fine, callback handles returning values, but there something bothers me. My browser, until the answer returns, and I do not know if this is due to the fact that during this time the node is actually blocked or not.
So, how can I find out if an operation is really blocking my node process? I thought that when you pass a callback to a function, node automatically processes it and puts the execution of this callback in the event loop queue. But I'm not so sure about that.
Does all this make sense to you?
source