Created
July 2, 2015 20:51
-
-
Save deontologician/89f0306a804d9062af65 to your computer and use it in GitHub Desktop.
domain error
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 r = require('rethinkdb'); | |
var domain = require('domain'); | |
var d = domain.create(); | |
r.connect({host: "127.0.0.1", port: "28015"}, function(err, connection){ | |
d.run(function(){ | |
// Demonstrate domain is preserved over setTimeout | |
setTimeout(function(){ | |
console.log("setTimeout has right domain:", process.domain === d); | |
}, 1); | |
// Demonstrate domain is lost over r.[query].run | |
r.expr(1).run(connection, function(){ | |
console.log("Callback has right domain:", process.domain === d); | |
}) | |
r.expr(1).run(connection).then(function(result){ | |
console.log("Promise has right domain:", process.domain === d); | |
}) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment