| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6f68570 commit 56adebf
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,13 +58,23 @@ const asyncHook = createHook({ | |||
| 58 | 58 | if (process.domain !== null && process.domain !== undefined) { | |
| 59 | 59 | // If this operation is created while in a domain, let's mark it | |
| 60 | 60 | pairing.set(asyncId, process.domain[kWeak]); | |
| 61 | - resource.domain = process.domain; | ||
| 61 | + Object.defineProperty(resource, 'domain', { | ||
| 62 | + configurable: true, | ||
| 63 | + enumerable: false, | ||
| 64 | + value: process.domain, | ||
| 65 | + writable: true | ||
| 66 | + }); | ||
| 62 | 67 | if (resource.promise !== undefined && | |
| 63 | 68 | resource.promise instanceof Promise) { | |
| 64 | 69 | // resource.promise instanceof Promise make sure that the | |
| 65 | 70 | // promise comes from the same context | |
| 66 | 71 | // see https://github.com/nodejs/node/issues/15673 | |
| 67 | - resource.promise.domain = process.domain; | ||
| 72 | + Object.defineProperty(resource.promise, 'domain', { | ||
| 73 | + configurable: true, | ||
| 74 | + enumerable: false, | ||
| 75 | + value: process.domain, | ||
| 76 | + writable: true | ||
| 77 | + }); | ||
| 68 | 78 | } | |
| 69 | 79 | } | |
| 70 | 80 | }, | |
@@ -203,7 +213,12 @@ Domain.prototype._errorHandler = function(er) { | |||
| 203 | 213 | var caught = false; | |
| 204 | 214 | ||
| 205 | 215 | if (!util.isPrimitive(er)) { | |
| 206 | - er.domain = this; | ||
| 216 | + Object.defineProperty(er, 'domain', { | ||
| 217 | + configurable: true, | ||
| 218 | + enumerable: false, | ||
| 219 | + value: this, | ||
| 220 | + writable: true | ||
| 221 | + }); | ||
| 207 | 222 | er.domainThrown = true; | |
| 208 | 223 | } | |
| 209 | 224 | ||
@@ -320,7 +335,12 @@ Domain.prototype.add = function(ee) { | |||
| 320 | 335 | } | |
| 321 | 336 | } | |
| 322 | 337 | ||
| 323 | - ee.domain = this; | ||
| 338 | + Object.defineProperty(ee, 'domain', { | ||
| 339 | + configurable: true, | ||
| 340 | + enumerable: false, | ||
| 341 | + value: this, | ||
| 342 | + writable: true | ||
| 343 | + }); | ||
| 324 | 344 | this.members.push(ee); | |
| 325 | 345 | }; | |
| 326 | 346 | ||
@@ -359,7 +379,12 @@ function intercepted(_this, self, cb, fnargs) { | |||
| 359 | 379 | var er = fnargs[0]; | |
| 360 | 380 | er.domainBound = cb; | |
| 361 | 381 | er.domainThrown = false; | |
| 362 | - er.domain = self; | ||
| 382 | + Object.defineProperty(er, 'domain', { | ||
| 383 | + configurable: true, | ||
| 384 | + enumerable: false, | ||
| 385 | + value: self, | ||
| 386 | + writable: true | ||
| 387 | + }); | ||
| 363 | 388 | self.emit('error', er); | |
| 364 | 389 | return; | |
| 365 | 390 | } | |
@@ -413,7 +438,12 @@ Domain.prototype.bind = function(cb) { | |||
| 413 | 438 | return bound(this, self, cb, arguments); | |
| 414 | 439 | } | |
| 415 | 440 | ||
| 416 | - runBound.domain = this; | ||
| 441 | + Object.defineProperty(runBound, 'domain', { | ||
| 442 | + configurable: true, | ||
| 443 | + enumerable: false, | ||
| 444 | + value: this, | ||
| 445 | + writable: true | ||
| 446 | + }); | ||
| 417 | 447 | ||
| 418 | 448 | return runBound; | |
| 419 | 449 | }; | |
@@ -423,7 +453,12 @@ EventEmitter.usingDomains = true; | |||
| 423 | 453 | ||
| 424 | 454 | const eventInit = EventEmitter.init; | |
| 425 | 455 | EventEmitter.init = function() { | |
| 426 | - this.domain = null; | ||
| 456 | + Object.defineProperty(this, 'domain', { | ||
| 457 | + configurable: true, | ||
| 458 | + enumerable: false, | ||
| 459 | + value: null, | ||
| 460 | + writable: true | ||
| 461 | + }); | ||
| 427 | 462 | if (exports.active && !(this instanceof exports.Domain)) { | |
| 428 | 463 | this.domain = exports.active; | |
| 429 | 464 | } | |
@@ -452,7 +487,12 @@ EventEmitter.prototype.emit = function(...args) { | |||
| 452 | 487 | ||
| 453 | 488 | if (typeof er === 'object') { | |
| 454 | 489 | er.domainEmitter = this; | |
| 455 | - er.domain = domain; | ||
| 490 | + Object.defineProperty(er, 'domain', { | ||
| 491 | + configurable: true, | ||
| 492 | + enumerable: false, | ||
| 493 | + value: domain, | ||
| 494 | + writable: true | ||
| 495 | + }); | ||
| 456 | 496 | er.domainThrown = false; | |
| 457 | 497 | } | |
| 458 | 498 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,13 +4,15 @@ require('../common'); | |||
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | const domain = require('domain'); | |
| 6 | 6 | const EventEmitter = require('events'); | |
| 7 | + const isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable); | ||
| 7 | 8 | ||
| 8 | 9 | const d = new domain.Domain(); | |
| 9 | 10 | const e = new EventEmitter(); | |
| 10 | 11 | const e2 = new EventEmitter(); | |
| 11 | 12 | ||
| 12 | 13 | d.add(e); | |
| 13 | 14 | assert.strictEqual(e.domain, d); | |
| 15 | + assert.strictEqual(isEnumerable(e, 'domain'), false); | ||
| 14 | 16 | ||
| 15 | 17 | // Adding the same event to a domain should not change the member count | |
| 16 | 18 | let previousMemberCount = d.members.length; | |
@@ -19,8 +21,10 @@ assert.strictEqual(previousMemberCount, d.members.length); | |||
| 19 | 21 | ||
| 20 | 22 | d.add(e2); | |
| 21 | 23 | assert.strictEqual(e2.domain, d); | |
| 24 | + assert.strictEqual(isEnumerable(e2, 'domain'), false); | ||
| 22 | 25 | ||
| 23 | 26 | previousMemberCount = d.members.length; | |
| 24 | 27 | d.remove(e2); | |
| 25 | 28 | assert.notStrictEqual(e2.domain, d); | |
| 29 | + assert.strictEqual(isEnumerable(e2, 'domain'), false); | ||
| 26 | 30 | assert.strictEqual(previousMemberCount - 1, d.members.length); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ const assert = require('assert'); | |||
| 6 | 6 | const async_hooks = require('async_hooks'); | |
| 7 | 7 | const domain = require('domain'); | |
| 8 | 8 | const EventEmitter = require('events'); | |
| 9 | + const isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable); | ||
| 9 | 10 | ||
| 10 | 11 | // This test makes sure that the (async id → domain) map which is part of the | |
| 11 | 12 | // domain module does not get in the way of garbage collection. | |
@@ -21,7 +22,9 @@ d.run(() => { | |||
| 21 | 22 | ||
| 22 | 23 | emitter.linkToResource = resource; | |
| 23 | 24 | assert.strictEqual(emitter.domain, d); | |
| 25 | + assert.strictEqual(isEnumerable(emitter, 'domain'), false); | ||
| 24 | 26 | assert.strictEqual(resource.domain, d); | |
| 27 | + assert.strictEqual(isEnumerable(resource, 'domain'), false); | ||
| 25 | 28 | ||
| 26 | 29 | // This would otherwise be a circular chain now: | |
| 27 | 30 | // emitter → resource → async id ⇒ domain → emitter. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,13 +4,15 @@ const common = require('../common'); | |||
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | const domain = require('domain'); | |
| 6 | 6 | const fs = require('fs'); | |
| 7 | + const isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable); | ||
| 7 | 8 | ||
| 8 | 9 | { | |
| 9 | 10 | const d = new domain.Domain(); | |
| 10 | 11 | ||
| 11 | 12 | d.on('error', common.mustCall((err) => { | |
| 12 | 13 | assert.strictEqual(err.message, 'foobar'); | |
| 13 | 14 | assert.strictEqual(err.domain, d); | |
| 15 | + assert.strictEqual(isEnumerable(err, 'domain'), false); | ||
| 14 | 16 | assert.strictEqual(err.domainEmitter, undefined); | |
| 15 | 17 | assert.strictEqual(err.domainBound, undefined); | |
| 16 | 18 | assert.strictEqual(err.domainThrown, true); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,12 +3,14 @@ | |||
| 3 | 3 | const common = require('../common'); | |
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | const domain = require('domain'); | |
| 6 | + const isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable); | ||
| 6 | 7 | ||
| 7 | 8 | const d = new domain.Domain(); | |
| 8 | 9 | ||
| 9 | 10 | d.on('error', common.mustCall((err) => { | |
| 10 | 11 | assert.strictEqual(err.message, 'foobar'); | |
| 11 | 12 | assert.strictEqual(err.domain, d); | |
| 13 | + assert.strictEqual(isEnumerable(err, 'domain'), false); | ||
| 12 | 14 | assert.strictEqual(err.domainEmitter, undefined); | |
| 13 | 15 | assert.strictEqual(err.domainBound, undefined); | |
| 14 | 16 | assert.strictEqual(err.domainThrown, true); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments