diff --git a/lib/auto.js b/lib/auto.js index eca7d5311..fe98e0659 100644 --- a/lib/auto.js +++ b/lib/auto.js @@ -108,7 +108,7 @@ export default function (tasks, concurrency, callback) { var runningTasks = 0; var hasError = false; - var listeners = {}; + var listeners = Object.create(null); var readyTasks = []; @@ -203,7 +203,7 @@ export default function (tasks, concurrency, callback) { }); safeResults[key] = args; hasError = true; - listeners = []; + listeners = Object.create(null); callback(err, safeResults); } else { diff --git a/mocha_test/auto.js b/mocha_test/auto.js index e2e55f9f3..489dbea0c 100644 --- a/mocha_test/auto.js +++ b/mocha_test/auto.js @@ -394,4 +394,43 @@ describe('auto', function () { isSync = false; }); + // Issue 1358 on github: https://github.com/caolan/async/issues/1358 + it('should report errors when a task name is an array method', function (done) { + async.auto({ + 'one': function (next) { + next('Something bad happened here'); + }, + 'filter': function (next) { + _.delay(function () { + next(null, 'All fine here though'); + }, 25); + }, + 'finally': ['one', 'filter', function (a, next) { + _.defer(next); + }] + }, function (err) { + expect(err).to.equal('Something bad happened here'); + _.delay(done, 30); + }); + }); + + it('should report errors when a task name is an obj prototype method', function (done) { + async.auto({ + 'one': function (next) { + next('Something bad happened here'); + }, + 'hasOwnProperty': function (next) { + _.delay(function () { + next(null, 'All fine here though'); + }, 25); + }, + 'finally': ['one', 'hasOwnProperty', function (a, next) { + _.defer(next); + }] + }, function (err) { + expect(err).to.equal('Something bad happened here'); + _.delay(done, 30); + }); + }); + });