From c9cd9773408299921ca3a0ef242af590e3ebb80f Mon Sep 17 00:00:00 2001 From: Bryan Donovan Date: Wed, 4 Feb 2015 18:46:18 -0800 Subject: [PATCH] wrapping callbacks in process.nextTick - seems to fix #21 --- lib/caching.js | 6 ++++-- lib/multi_caching.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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]; }