jeudi 16 avril 2015

Trouble setting timeout in node js error handler (domains)

I have a domain exception handler (wrapper for nightwatch tests).


This is my exception handler wrapper -



var domainError = function(func) {

return function() {
var d = domain.create().on('error', function(err) {
console.error(err.stack);
});

d.enter();
try {
return func.apply(this, arguments);
}
catch (err) {
//do something with the err
}
d.exit();
}
};


I am trying to set timeouts so that "return func.apply(this, arguments);" doesn't take forever. Could anyone suggest how I can add timeouts and make the domain end the function and exit, if it exceeds timeout?


Aucun commentaire:

Enregistrer un commentaire