Browse Source

Merge branch 'release/1.2.2'

feature/remove-domains
Bryan Donovan 10 years ago
parent
commit
eb52818430
  1. 3
      History.md
  2. 6
      lib/multi_caching.js
  3. 2
      package.json
  4. 26
      test/multi_caching.unit.js

3
History.md

@ -1,3 +1,6 @@
- 1.2.2 2015-10-19
- Bugfix: Fixing domain error issues when error is thrown inside 'work' function (#28).
- 1.2.1 2015-10-17
- Bugfix: multi-caching: using underlying store's isCacheableValue function when it exists (#34).

6
lib/multi_caching.js

@ -163,7 +163,11 @@ var multiCaching = function(caches, options) {
domain
.create()
.on('error', function(err) {
callbackFiller.fill(key, err);
if (callbackFiller.has(key)) {
callbackFiller.fill(key, err);
} else {
cb(err);
}
})
.bind(work)(function(err, data) {
if (err) {

2
package.json

@ -1,6 +1,6 @@
{
"name": "cache-manager",
"version": "1.2.1",
"version": "1.2.2",
"description": "Cache module for Node.js",
"main": "index.js",
"scripts": {

26
test/multi_caching.unit.js

@ -388,6 +388,7 @@ describe("multiCaching", function() {
checkErr(err);
assert.deepEqual(widget, {name: name});
sinon.assert.calledWith(memoryCache3.store.set, key, {name: name}, {ttl: defaultTtl});
done();
});
});
@ -866,6 +867,31 @@ describe("multiCaching", function() {
});
});
context("when an error is thrown in the work function's callback", function() {
var fakeError;
beforeEach(function() {
fakeError = new Error(support.random.string());
});
it("bubbles up that error", function(done) {
multiCache.wrap(key, function(next) {
next();
}, ttl, function() {
// This test as-is doesn't prove a fix for #28 (https://github.com/BryanDonovan/node-cache-manager/issues/28)
// but if you remove the try/catch, it shows that the undefined `waiting` array issue
// is no longer present (the domain doesn't try to process the error in the callbackFiller).
try {
throw new Error('foo');
} catch (e) {
assert.equal(e.message, 'foo');
}
done();
});
});
});
context("when store.get() calls back with an error", function() {
it("bubbles up that error", function(done) {
var fakeError = new Error(support.random.string());

Loading…
Cancel
Save