Lines Matching refs:domain

59 // Overwrite process.domain with a getter/setter that will allow for more
62 ObjectDefineProperty(process, 'domain', {
77 if (process.domain !== null && process.domain !== undefined) {
78 // If this operation is created while in a domain, let's mark it
79 pairing.set(asyncId, process.domain[kWeak]);
81 // have a domain property as it can be used to escape the sandbox.
83 ObjectDefineProperty(resource, 'domain', {
87 value: process.domain,
90 // Because promises from other contexts don't get a domain field,
91 // the domain needs to be held alive another way. Stuffing it in a
94 vmPromises.set(resource, process.domain);
100 if (current !== undefined) { // Enter domain for this cb
101 // We will get the domain through current.get(), because the resource
102 // object's .domain property makes sure it is not garbage collected.
103 // However, we do need to make the reference to the domain non-weak,
111 if (current !== undefined) { // Exit domain for this cb
112 const domain = current.get();
114 domain.exit();
128 // Get the stack trace at the point where `domain` was required.
130 const domainRequireStack = new Error('require(`domain`) at this point').stack;
144 'Using a domain property in MakeCallback is deprecated. Use the ' +
155 const domain = this.domain;
156 if (exports.active && domain)
159 if (domain)
160 domain.enter();
162 if (domain)
163 domain.exit();
168 // It's possible to enter one domain while already inside
169 // another one. The stack is each entered domain.
176 (domain) => domain.listenerCount('error') === 0)) {
181 return process.domain._errorHandler(er);
191 // the domain stack.
200 // If the domain listener would be the only remaining one, remove it.
209 exports.active = process.domain = null;
233 // The active domain is always the one that we're currently in.
242 ObjectDefineProperty(er, 'domain', {
251 // Pop all adjacent duplicates of the currently active domain from the stack.
252 // This is done to prevent a domain's error handler to run within the context
259 // The top-level domain-handler is handled separately.
264 // in the top-level domain error handler to make the
275 // the top-level domain is not active anymore, it would be ok to abort on
294 // the domain, because we're going to crash the process anyway.
297 // The domain error handler threw! oh no!
298 // See if another domain can catch THIS error,
302 exports.active = process.domain = stack[stack.length - 1];
303 caught = process.domain._errorHandler(er2);
323 exports.active = process.domain = this;
330 // Don't do anything if this domain is not on the stack.
338 process.domain = exports.active;
345 // If the domain is already added, then nothing left to do.
346 if (ee.domain === this)
349 // Has a domain already - remove it first.
350 if (ee.domain)
351 ee.domain.remove(ee);
357 // var d = domain.create();
358 // var e = domain.create();
362 if (this.domain && (ee instanceof Domain)) {
363 for (let d = this.domain; d; d = d.domain) {
368 ObjectDefineProperty(ee, 'domain', {
380 ee.domain = null;
401 ObjectDefineProperty(er, 'domain', {
447 ObjectDefineProperty(runBound, 'domain', {
458 // Override EventEmitter methods to make it domain-aware.
463 ObjectDefineProperty(this, 'domain', {
471 this.domain = exports.active;
479 const domain = this.domain;
486 // handler, there's no active domain or this is process
487 if (shouldEmitError || domain === null || domain === undefined ||
498 ObjectDefineProperty(er, 'domain', {
502 value: domain,
508 // Remove the current domain (and its duplicates) from the domains stack and
509 // set the active domain to its parent (if any) so that the domain's error
514 const origActiveDomain = process.domain;
516 // Travel the domains stack from top to bottom to find the first domain
517 // instance that is not a duplicate of the current active domain.
519 while (idx > -1 && process.domain === stack[idx]) {
523 // Change the stack to not contain the current active domain, and only the
531 // Change the current active domain
533 exports.active = process.domain = stack[stack.length - 1];
535 exports.active = process.domain = null;
540 domain.emit('error', er);
542 // Now that the domain's error handler has completed, restore the domains
543 // stack and the active domain to their original values.
545 exports.active = process.domain = origActiveDomain;
551 domain.enter();
553 domain.exit();