Skip to content

Instantly share code, notes, and snippets.

@mde
Created July 9, 2014 19:17
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 mde/5e01d8d5a46c0a8a9e0f to your computer and use it in GitHub Desktop.
Save mde/5e01d8d5a46c0a8a9e0f to your computer and use it in GitHub Desktop.
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