Setting timeout in node js domain error handler

18 views
Skip to first unread message

Rajaggan

unread,
Apr 16, 2015, 1:53:04 PM4/16/15
to nod...@googlegroups.com

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?

Thanks

Reply all
Reply to author
Forward
0 new messages