generic-pool
Advanced tools
Comparing version 2.4.2 to 2.4.3
# Change Log | ||
## [2.4.3] - October 15 2016 | ||
- Use domain.bind to preserve domain context (@LewisJEllis) | ||
## [2.4.2] - March 26 2016 | ||
@@ -4,0 +7,0 @@ - Travis now runs and fails lint checks (@kevinburke) |
@@ -387,2 +387,5 @@ /** | ||
} | ||
if (process.domain) { | ||
callback = process.domain.bind(callback) | ||
} | ||
this._waitingClients.enqueue(callback, priority) | ||
@@ -389,0 +392,0 @@ this._dispense() |
{ | ||
"name": "generic-pool", | ||
"description": "Generic resource pooling for Node.JS", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"author": "James Cooper <james@bitmechanic.com>", | ||
@@ -50,2 +50,6 @@ "contributors": [ | ||
"email": "james.butler@sandfox.co.uk" | ||
}, | ||
{ | ||
"name": "Lewis J Ellis", | ||
"email": "me@lewisjellis.com" | ||
} | ||
@@ -52,0 +56,0 @@ ], |
@@ -750,3 +750,49 @@ var assert = require('assert') | ||
}) | ||
}, | ||
'domain context is preserved on acquire callback': function (beforeExit) { | ||
var assertion_count = 0 | ||
var pool = poolModule.Pool({ | ||
name: 'test', | ||
create: function (cb) { | ||
cb(null, {}) | ||
}, | ||
destroy: function (client) {}, | ||
max: 2, | ||
idleTimeoutMillis: 1000 | ||
}) | ||
// bail on old node versions because domains didn't exist until v0.8 | ||
if (process.version < 'v0.8') { | ||
return | ||
} | ||
var domain = require('domain') | ||
function check (index) { | ||
var wrapDomain = domain.create() | ||
wrapDomain.index = index | ||
wrapDomain.run(function () { | ||
pool.acquire(function (err, client) { | ||
assert.ifError(err) | ||
assert.equal(domain.active.index, index) | ||
assertion_count++ | ||
setTimeout(function () { | ||
pool.release(client) | ||
}, 50) | ||
}) | ||
}) | ||
} | ||
// first two will work even without domain binding | ||
check(1) | ||
check(2) | ||
// third and on will fail without domain binding | ||
check(3) | ||
beforeExit(function () { | ||
assert.equal(assertion_count, 3) | ||
}) | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59585
10
1220