diff --git a/lib/caching.js b/lib/caching.js index 490de42..60ed92e 100644 --- a/lib/caching.js +++ b/lib/caching.js @@ -51,8 +51,10 @@ var caching = function(args) { function fillCallbacks(err, data) { self.queues[key].forEach(function(task) { - var taskDomain = task.domain || domain.create(); - taskDomain.bind(task.cb)(err, data); + process.nextTick(function() { + var taskDomain = task.domain || domain.create(); + taskDomain.bind(task.cb)(err, data); + }); }); delete self.queues[key]; } diff --git a/lib/multi_caching.js b/lib/multi_caching.js index 2719a19..6b6086b 100644 --- a/lib/multi_caching.js +++ b/lib/multi_caching.js @@ -79,8 +79,10 @@ var multi_caching = function(caches) { function fillCallbacks(err, data) { self.queues[key].forEach(function(task) { - var taskDomain = task.domain || domain.create(); - taskDomain.bind(task.cb)(err, data); + process.nextTick(function() { + var taskDomain = task.domain || domain.create(); + taskDomain.bind(task.cb)(err, data); + }); }); delete self.queues[key]; }