This package has been deprecated

Author message:

no longer relevant in modern versions of node

domainit

0.1.1 • Public • Published

domainit - wrap a function with the safety of a domain

Wrap a function with the warm comfort of a node domain using standard callbacks.

Build Status Dependency Status

var assert = require('assert');
var domainit = require('domainit');

function unsafe(cb) {
  process.nextTick(function () {
    throw new Error('Oops!');
  });
}

var safe = domainit(unsafe);
safe(function (err) {
  assert(err);
  assert(err.message === 'Oops!');
});

warning for node < v0.9.5

Versions of Node before v0.9.5 raise uncaughtException events despite errors being handled within a domain. You shouldn't need to handle uncaughtException if you are working with domains.

Some testing frameworks, like mocha, bind to the uncaughtException event. This will wrongly cause tests to fail when errors occur within a domain on Node versions < 0.9.5.

Check out the relevant issue on GitHub.

Readme

Keywords

none

Package Sidebar

Install

npm i domainit

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • mpareja