[Pkg-javascript-commits] [node-async] 252/480: force nextTick on auto calls to prevent double task execution when synchronous

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:31 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit 25c776de9d5bb5791a9c40030b1be7cfa26c1ead
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date:   Thu Jan 31 14:00:32 2013 +0000

    force nextTick on auto calls to prevent double task execution when synchronous
---
 lib/async.js | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/async.js b/lib/async.js
index b5ba2ea..b3c25d6 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -406,7 +406,6 @@
         });
 
         _forEach(keys, function (k) {
-            var fired = false;
             var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k];
             var taskCallback = function (err) {
                 if (err) {
@@ -420,14 +419,14 @@
                         args = args[0];
                     }
                     results[k] = args;
-                    taskComplete();
+                    process.nextTick(taskComplete);
                 }
             };
             var requires = task.slice(0, Math.abs(task.length - 1)) || [];
             var ready = function () {
                 return _reduce(requires, function (a, x) {
                     return (a && results.hasOwnProperty(x));
-                }, true) && !fired;
+                }, true) && !results.hasOwnProperty(k);
             };
             if (ready()) {
                 task[task.length - 1](taskCallback, results);
@@ -436,7 +435,6 @@
                 var listener = function () {
                     if (ready()) {
                         removeListener(listener);
-                        fired = true;
                         task[task.length - 1](taskCallback, results);
                     }
                 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list