5

How do I set a timeout for a mysql query in node.js?

/*...*/ 

var mysql = require("mysql");

/* ...*/ 

app.get("/", function(req, res) { 
     connection.query("SELECT ...", function(err, rows, fields) {
 /* I want this query to fail if the ^_ callback is not invoked within x seconds */

     });
}

1 Answer 1

2

I suggest you look up this link:

http://www.exratione.com/2013/01/nodejs-connections-will-end-close-and-otherwise-blow-up/

But the module doesn't seems to have any support for it at the moment.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer. So what would be an alternative? Without the timeout functionality, it seems that the module is not suitable for production.. hmm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.