Skip to content

Instantly share code, notes, and snippets.

@mde mde/riakpbc domains
Created Jul 9, 2014

Embed
What would you like to do?
var http = require('http')
, domain = require('domain')
, riakpbc = require('./index')
, riak = riakpbc.createClient({host: 'localhost', port: 8087});
http.createServer(function (req, res) {
var dmn = domain.create();
dmn.on('error', function (err) {
console.dir(arguments);
console.log('Domain caught error');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(err.message + '\n');
});
dmn.run(function () {
/*
setTimeout(function () {
// Domain correctly catches this
throw new Error('HELP COMPUTER');
}, 0);
*/
riak.getServerInfo(function (err, reply) {
console.log('Riak returned:', arguments);
// Domain does not catch this
throw new Error('Uhhh ... what the hell?');
});
});
}).listen(1337, '127.0.0.1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.