Skip to content

Instantly share code, notes, and snippets.

@deontologician
Created July 2, 2015 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deontologician/89f0306a804d9062af65 to your computer and use it in GitHub Desktop.
Save deontologician/89f0306a804d9062af65 to your computer and use it in GitHub Desktop.
domain error
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