Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
domain.create().run(function() {
domain.create().on('error', function(e) {
// Don't need to do anything here
}).run(function() {
throw new Error('died');
});
});
});
it(behavior, function(done) {
var d = domain.create();
d.on('error', function(err) {
done(err);
});
d.run(function() {
test(done);
});
});
};
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');
});
});
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');
});
});
});
}
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');
});
});
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');
});
function test() {
const d = domain.create();
d.run(function() {
const fs = require('fs');
fs.exists('/non/existing/file', function onExists() {
throw new Error('boom!');
});
});
}
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!');
});
});
});
}
function createDomain() {
var domain = require('domain').create();
domains.push(domain);
return domain;
};
}).then(function () {
process.domain = process.domain || require('domain').create();
process.domain.req = {};
done();
}).catch(done);
});