Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var self = this;
var ret = '';
// look for error context in 3 places, in ascending order of precedence:
// 1) raw fields on the error object that are not known verror or
// restify-error fields
// 2) restify-error context fields (restify-errors@ <= 5.x)
// 3) verror info field
var topLevelFields = (self._serializeTopLevelFields === true) ?
_.omit(err, self._knownFields) :
{};
// We don't want to load domains just to check if topLevelFields.domain is
// a Domain instance, so first we make sure domains are already loaded.
if (EventEmitter.usingDomains) {
if (!domain) {
// eslint-disable-next-line global-require
domain = require('domain');
}
if (topLevelFields.domain instanceof domain.Domain) {
topLevelFields = _.omit(topLevelFields, [ 'domain' ]);
}
}
// combine all fields into a pojo, and serialize
var allFields = _.assign({}, topLevelFields, err.context, nerror.info(err));
if (!_.isEmpty(allFields)) {
ret = ' (' + serializeIntoEqualString(allFields) + ')';
}
function runBound() {
return bound(this, self, cb, arguments);
}
Object.defineProperty(runBound, 'domain', {
configurable: true,
enumerable: false,
value: this,
writable: true
});
return runBound;
};
// Override EventEmitter methods to make it domain-aware.
EventEmitter.usingDomains = true;
const eventInit = EventEmitter.init;
EventEmitter.init = function() {
Object.defineProperty(this, 'domain', {
configurable: true,
enumerable: false,
value: null,
writable: true
});
if (exports.active && !(this instanceof exports.Domain)) {
this.domain = exports.active;
}
return eventInit.call(this);
};
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var util = require('util');
var events = require('events');
var EventEmitter = events.EventEmitter;
var inherits = util.inherits;
// methods that are called when trying to shut down expliclitly bound EEs
var endMethods = ['end', 'abort', 'destroy', 'destroySoon'];
// communicate with events module, but don't require that
// module to have to load this one, since this module has
// a few side effects.
events.usingDomains = true;
// let the process know we're using domains
process._usingDomains();
exports.Domain = Domain;
exports.create = exports.createDomain = function(cb) {
return new Domain(cb);
};
// it's possible to enter one domain while already inside
// another one. the stack is each entered domain.
var stack = [];
exports._stack = stack;
// the active domain is always the one that we're currently in.
exports.active = null;
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var util = require('util');
var EventEmitter = require('events');
var inherits = util.inherits;
// communicate with events module, but don't require that
// module to have to load this one, since this module has
// a few side effects.
EventEmitter.usingDomains = true;
// overwrite process.domain with a getter/setter that will allow for more
// effective optimizations
var _domain = [null];
Object.defineProperty(process, 'domain', {
enumerable: true,
get: function() {
return _domain[0];
},
set: function(arg) {
return _domain[0] = arg;
}
});
// objects with external array data are excellent ways to communicate state
// between js and c++ w/o much overhead
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var util = require('util');
var EventEmitter = require('events');
var inherits = util.inherits;
// communicate with events module, but don't require that
// module to have to load this one, since this module has
// a few side effects.
EventEmitter.usingDomains = true;
// overwrite process.domain with a getter/setter that will allow for more
// effective optimizations
var _domain = [null];
Object.defineProperty(process, 'domain', {
enumerable: true,
get: function() {
return _domain[0];
},
set: function(arg) {
return _domain[0] = arg;
}
});
// objects with external array data are excellent ways to communicate state
// between js and c++ w/o much overhead
return function () {
if (Events.usingDomains && ee.domain) {
ee.domain.enter();
fn.apply(this, arguments);
ee.domain.exit();
} else {
fn.apply(this, arguments);
}
};
}
return function () {
if (Events.usingDomains && ee.domain) {
ee.domain.enter();
fn.apply(this, arguments);
ee.domain.exit();
} else {
fn.apply(this, arguments);
}
};
}
constructor: function SequentialExecutor() {
this.domain = null;
if (require('events').usingDomains) {
domain = require('domain');
if (domain.active) this.domain = domain.active;
}
this._events = {};
},
}
};
Async.prototype._getDomain = function() {};
if (!false) {
if (util.isNode) {
var EventsModule = require("events");
var domainGetter = function() {
var domain = process.domain;
if (domain === null) return undefined;
return domain;
};
if (EventsModule.usingDomains) {
Async.prototype._getDomain = domainGetter;
} else {
var descriptor =
Object.getOwnPropertyDescriptor(EventsModule, "usingDomains");
if (descriptor) {
if (!descriptor.configurable) {
process.on("domainsActivated", function() {
Async.prototype._getDomain = domainGetter;
});
} else {
var usingDomains = false;
Object.defineProperty(EventsModule, "usingDomains", {
configurable: false,
enumerable: true,
get: function() {
}
};
Async.prototype._getDomain = function() {};
if (!false) {
if (util.isNode) {
var EventsModule = require("events");
var domainGetter = function() {
var domain = process.domain;
if (domain === null) return undefined;
return domain;
};
if (EventsModule.usingDomains) {
Async.prototype._getDomain = domainGetter;
} else {
var descriptor =
Object.getOwnPropertyDescriptor(EventsModule, "usingDomains");
if (descriptor) {
if (!descriptor.configurable) {
process.on("domainsActivated", function() {
Async.prototype._getDomain = domainGetter;
});
} else {
var usingDomains = false;
Object.defineProperty(EventsModule, "usingDomains", {
configurable: false,
enumerable: true,
get: function() {