Closed
Description
What version of async are you using?
2.1.4
Which environment did the issue occur in (Node version/browser version)
Node 6.9.4
What did you do? Please include a minimal reproducable case illustrating issue.
const _ = require('lodash');
const async = require('async');
async.auto({
'one': function (next) {
_.defer(function () {
console.info('Error');
next('Something bad happened here');
});
},
'filter': function (next) {
_.delay(function () {
console.info('Fine');
next(null, 'All fine here though');
}, 1000);
},
'finally': ['one', 'filter', function (a, next) {
_.defer(next);
}]
}, function (err, auto) {
if (err) {
console.error(`Caught: ${err}`);
} else {
console.info(auto);
}
});
What did you expect to happen?
Logs error but doesn't raise exception.
What was the actual result?
TypeError: fn is not a function
at C:\somewhere\node_modules\async\dist\async.js:1594:13
at arrayEach (C:\somewhere\node_modules\async\dist\async.js:1298:9)
at taskComplete (C:\somewhere\node_modules\async\dist\async.js:1593:9)
at C:\somewhere\node_modules\async\dist\async.js:1619:17
at apply (C:\somewhere\node_modules\async\dist\async.js:21:25)
at C:\somewhere\node_modules\async\dist\async.js:56:12
at breakLoop (C:\somewhere\node_modules\async\dist\async.js:840:16)
... cut ...
This is because of:
listeners
variable initially declared as an object, being transformed to array at some point (line 1614) for some reason, which is a bad idea in general.- Even if it was an object at that point, it doesn't guarantee anything, without additional
hasOwnProperty
check. Someone might as well call taskhasOwnProperty
.
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
fix for #1358
aearly commentedon Jan 31, 2017
I have a fix for this. I couldn't reproduce the error in a test case for some reason, but I see exactly how it is caused.
publish: fix for caolan#1358