error not caught when using domains
Closed this issue · 3 comments
tomyan commented
I'm trying to use domains to catch errors in certain contexts. When I call done() at the end of a promise chain to ensure failures are raised as exceptions, these exceptions somehow leak out of the domain. Here's a simple example of the problem - switch it out to use Q to see the behaviour I was expecting:
var p = require('p-promise');
//var p = require('Q');
var domain = require('domain'),
d = domain.create();
d.on('error', function (err) {
console.log('got error in domain:', err.message);
});
process.on('error', function (err) {
console.log('got error in process:', err.message);
});
d.run(function () {
var deferred = p.defer();
deferred.promise.done();
deferred.reject(new Error('foo'));
});
Thanks
Tom
rkatic commented
rkatic commented
With last changes I also added support for domains.
However, it is still not tested properly.
Will close this when I will have some domain related tests.