Created
August 24, 2013 10:43
-
-
Save iliakan/6327393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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