async.waterfall breaks when given an async function (node 8)
See original GitHub issueWhat version of async are you using? 2.5.0
Which environment did the issue occur in (Node version/browser version) Node 8
What did you do? Please include a minimal reproducable case illustrating issue.
async=require('async')
async function myFirstFunction(callback) {
callback(null, 'one', 'two');
}
function mySecondFunction(arg1, arg2, callback) {
// arg1 now equals 'one' and arg2 now equals 'two'
callback(null, 'three');
}
async function myLastFunction(arg1, callback) {
// arg1 now equals 'three'
callback(null, 'done');
}
async.waterfall([
myFirstFunction,
mySecondFunction,
myLastFunction,
], function (err, result) {
// result now equals 'done'
console.log(err, result)
});
What did you expect to happen? to not have an exception
What was the actual result?
> TypeError: callback is not a function
at myFirstFunction (repl:2:5)
at /Users/scott/node_modules/async/dist/async.js:143:27
at /Users/scott/node_modules/async/dist/async.js:21:12
at nextTask (/Users/scott/node_modules/async/dist/async.js:5297:14)
at Object.waterfall (/Users/scott/node_modules/async/dist/async.js:5307:5)
at repl:1:7
at ContextifyScript.Script.runInThisContext (vm.js:44:33)
at REPLServer.defaultEval (repl.js:239:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12) undefined
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:13
Top Results From Across the Web
I use async waterfall, why callback is not a function?
When you use async in a function inside the waterfall, there's no callback argument. Instead of calling callback(null, data) you resolve ...
Read more >ES2017's async/await is the best thing to ever happen to ...
await - is a way to await until a promise has returned a value (resolved). Error handling is plain old JavaScript: if something...
Read more >Node.js Async Best Practices & Avoiding the Callback Hell
This post covers what tools and techniques you have at your disposal when handling Node.js asynchronous operations. Learn how to avoid the ...
Read more >async.mjs
This is useful for plugging sync functions into a waterfall, * series, or other async functions. Any arguments passed to the generated *...
Read more >Top 10 Most Common Node.js Developer Mistakes - Toptal
js package that deals with asynchronous JavaScript patterns, such as Async.js: function handleLogin(done) { async.waterfall([ function( ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, you could do something like:
Then how to return error? Just using throw?