Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var domain = require('domain');
var mysql = require('mysql');
var pool = mysql.createPool({
host: '127.0.0.1',
port: 3306,
database: 'test',
user: 'localuser',
password: 'localpass',
});
var requestDomain = domain.create();
requestDomain.on("error", function(err) {
console.log("DOMAIN: %s", err);
});
pool.getConnection(function(err, connection) {
connection.end();
AND_HERE_WE_GO({}, {});
})
function AND_HERE_WE_GO(req, res) {
requestDomain.run(function() {
pool.getConnection(function(err, connection) {
// connected! (unless `err` is set)
connection.query('SELECT 1', function(err, rows) {
throw new Error("BOOM!")
});
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment