Skip to content

Mixing native async and Node callback functions seems to cause unexpected behavior #1964

Closed
@bbuck

Description

@bbuck

It seems async functions that return nothing (implicitly resolves to undefined) pass on undefined as a value to the next function in line which I would not expect to happen. Returning undefined from a function is the default behavior of "returning nothing."

What version of async are you using?

3.2.4

Which environment did the issue occur in (Node/browser/Babel/Typescript version)
Node 18 (18.20.2 specifically)

What did you do? Please include a minimal reproducible case illustrating issue.

async.waterfall(
  [
    async () => {}, 
    (...args) => { 
      args.at(-1)(null, args); 
    },
  ],
  (error, result) => {
    console.log('error', error, '// result', result);
  },
);

// > error null // result [ undefined, [Function (anonymous)] ]

What did you expect to happen?

The result array to have a single element, the callback function.

What was the actual result?

The array contains two items, the undefined resolved from the native async function and the callback function passed to the Node-style async function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions