Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

async.waterfall breaks when given an async function (node 8)

See original GitHub issue

What 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 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');
], 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:13

github_iconTop GitHub Comments

aearlycommented, Oct 5, 2017

Yeah, you could do something like:

  // ...
  async function (arg1, arg2) {
    const arg3 = await foo()
    return [arg1, arg2, arg3]
  function ([arg1, arg2, arg3], callback) {
chak774commented, Jan 4, 2019

Then how to return error? Just using throw?

Read more comments on GitHub >

github_iconTop 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 >
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found