Skip to content

Commit 8903d46

Browse files
committed
fix for caolan#1358
1 parent 5188c84 commit 8903d46

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

lib/auto.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default function (tasks, concurrency, callback) {
108108
var runningTasks = 0;
109109
var hasError = false;
110110

111-
var listeners = {};
111+
var listeners = Object.create(null);
112112

113113
var readyTasks = [];
114114

@@ -203,7 +203,7 @@ export default function (tasks, concurrency, callback) {
203203
});
204204
safeResults[key] = args;
205205
hasError = true;
206-
listeners = [];
206+
listeners = Object.create(null);
207207

208208
callback(err, safeResults);
209209
} else {

mocha_test/auto.js

+39
Original file line numberDiff line numberDiff line change
@@ -394,4 +394,43 @@ describe('auto', function () {
394394
isSync = false;
395395
});
396396

397+
// Issue 1358 on github: https://github.com/caolan/async/issues/1358
398+
it('should report errors when a task name is an array method', function (done) {
399+
async.auto({
400+
'one': function (next) {
401+
next('Something bad happened here');
402+
},
403+
'filter': function (next) {
404+
_.delay(function () {
405+
next(null, 'All fine here though');
406+
}, 25);
407+
},
408+
'finally': ['one', 'filter', function (a, next) {
409+
_.defer(next);
410+
}]
411+
}, function (err) {
412+
expect(err).to.equal('Something bad happened here');
413+
_.delay(done, 30);
414+
});
415+
});
416+
417+
it('should report errors when a task name is an obj prototype method', function (done) {
418+
async.auto({
419+
'one': function (next) {
420+
next('Something bad happened here');
421+
},
422+
'hasOwnProperty': function (next) {
423+
_.delay(function () {
424+
next(null, 'All fine here though');
425+
}, 25);
426+
},
427+
'finally': ['one', 'hasOwnProperty', function (a, next) {
428+
_.defer(next);
429+
}]
430+
}, function (err) {
431+
expect(err).to.equal('Something bad happened here');
432+
_.delay(done, 30);
433+
});
434+
});
435+
397436
});

0 commit comments

Comments
 (0)