Skip to content

Commit

Permalink
fix for #1358
Browse files Browse the repository at this point in the history
  • Loading branch information
aearly committed Jan 31, 2017
1 parent 5188c84 commit 8903d46
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/auto.js
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -203,7 +203,7 @@ export default function (tasks, concurrency, callback) {
});
safeResults[key] = args;
hasError = true;
listeners = [];
listeners = Object.create(null);

callback(err, safeResults);
} else {
Expand Down
39 changes: 39 additions & 0 deletions mocha_test/auto.js
Expand Up @@ -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);
});
});

});

0 comments on commit 8903d46

Please sign in to comment.