[Pkg-javascript-commits] [node-async] 370/480: Fix 'auto calls callback multiple times' Issue #410

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:43 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 be9eb1075c0693207de471cfdc46f186240b9e45
Author: James Cox <th3james at gmail.com>
Date:   Mon Dec 2 21:54:24 2013 +0000

    Fix 'auto calls callback multiple times' Issue #410
---
 lib/async.js       | 5 ++++-
 test/test-async.js | 7 +++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/async.js b/lib/async.js
index cb6320d..0e19b35 100755
--- a/lib/async.js
+++ b/lib/async.js
@@ -419,8 +419,11 @@
 
         addListener(function () {
             if (_keys(results).length === keys.length) {
-                callback(null, results);
+                var theCallback = callback;
+                // prevent final callback from calling itself if it errors
                 callback = function () {};
+
+                theCallback(null, results);
             }
         });
 
diff --git a/test/test-async.js b/test/test-async.js
index 39d61be..62c3880 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -442,12 +442,11 @@ exports['auto calls callback multiple times'] = function(test) {
     // Final callback. This should only run once...
     function(err) {
         finalCallCount++;
-        console.log('Called ' + finalCallCount + ' times');
         if (finalCallCount > 1) {
-          test.done(new Error("Final auto callback should only be called once"));
+            test.done(new Error("Final auto callback should only be called once"));
         } else {
-          test.done();
-          throw new Error("An error");
+            test.done();
+            throw new Error("An error");
         }
     });
 };

-- 
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