From 1e5cd0f9357431b0590c75e0857dc316fb329a0c Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Thu, 18 Sep 2014 10:04:39 -0500 Subject: [PATCH] Execute queued callbacks on error. --- lib/caching.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/caching.js b/lib/caching.js index e348a4d..02b26b0 100644 --- a/lib/caching.js +++ b/lib/caching.js @@ -48,7 +48,17 @@ var caching = function (args) { work(function () { var work_args = Array.prototype.slice.call(arguments, 0); if (work_args[0]) { // assume first arg is an error - return cb(work_args[0]); + if (!self.ignoreCacheErrors) { + self.queues[key].forEach(function (done) { + done.apply(null, work_args); + }); + delete self.queues[key]; + } + else { + cb(work_args[0]); + } + + return; } // Subsequently assume second arg is result. self.store.set(key, work_args[1], function (err) {