How to use the domain.create function in domain

To help you get started, we’ve selected a few domain examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graalvm / graaljs / test / parallel / test-domain-nested.js View on Github external
domain.create().run(function() {
      domain.create().on('error', function(e) {
        // Don't need to do anything here
      }).run(function() {
        throw new Error('died');
      });
    });
  });
github appium / appium / test / helpers / driverblock.js View on Github external
it(behavior, function(done) {
    var d = domain.create();
    d.on('error', function(err) {
      done(err);
    });
    d.run(function() {
      test(done);
    });
  });
};
github graalvm / graaljs / test / fixtures / uncaught-exceptions / domain.js View on Github external
const domain = require('domain');

var d = domain.create();
d.on('error', function(err) {
  console.log('[ignored]', err.stack);
});

d.run(function() {
  setImmediate(function() {
    throw new Error('in domain');
  });
});
github ruipgil / scraperjs / test / ScraperPromise.js View on Github external
it('error without catch', function(done) {
			var d = domain.create();
			d.on('error', function(err) {
				assert.equal(err.message, 'random message');
				done();
			});
			d.run(function() {
				new ScraperPromise(new ScraperType())
					.get(HN_CLONE)
					.then(function() {
						throw new Error('random message');
					});
			});
		});
	}
github joshfire / woodman / test / spec / patternlayout.spec.js View on Github external
it('follows nested keys to output the domain (%domain)', function () {
      var layout = new PatternLayout({
        pattern: '%domain{nested.name.id}'
      }, loggerContext);
      var evt = new LogEvent('loggername', 'warn', new Message('timber!'));
      var d = domain.create();
      d.nested = {};
      d.nested.name = {};
      d.nested.name.id = 'mydomain';
      var toMessageString = layout.toMessageString.bind(layout);
      toMessageString = d.bind(toMessageString);
      expect(toMessageString(evt)).toEqual('mydomain');
    });
  });
github joshfire / woodman / test / spec / patternlayout.spec.js View on Github external
it('uses the provided ID key to output the domain (%domain)', function () {
      var layout = new PatternLayout({
        pattern: '%domain{name}'
      }, loggerContext);
      var evt = new LogEvent('loggername', 'warn', new Message('timber!'));
      var d = domain.create();
      d.name = 'mydomain';
      var toMessageString = layout.toMessageString.bind(layout);
      toMessageString = d.bind(toMessageString);
      expect(toMessageString(evt)).toEqual('mydomain');
    });
github graalvm / graaljs / test / parallel / test-domain-no-error-handler-abort-on-uncaught-5.js View on Github external
function test() {
  const d = domain.create();

  d.run(function() {
    const fs = require('fs');
    fs.exists('/non/existing/file', function onExists() {
      throw new Error('boom!');
    });
  });
}
github graalvm / graaljs / test / parallel / test-domain-no-error-handler-abort-on-uncaught-9.js View on Github external
function test() {
  const d = domain.create();
  const d2 = domain.create();

  d.on('error', function errorHandler() {
  });

  d.run(() => {
    d2.run(() => {
      const fs = require('fs');
      fs.exists('/non/existing/file', function onExists() {
        throw new Error('boom!');
      });
    });
  });
}
github aws / aws-sdk-js / test / event_listeners.spec.js View on Github external
function createDomain() {
            var domain = require('domain').create();
            domains.push(domain);
            return domain;
          };
github jsreport / jsreport / test / helpers.js View on Github external
}).then(function () {
                process.domain = process.domain || require('domain').create();
                process.domain.req = {};
                done();
            }).catch(done);
        });

domain

domain for javascript

AGPL-3.0
Latest version published 10 years ago

Package Health Score

42 / 100
Full package analysis

Popular domain functions