-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixing native async and Node callback functions seems to cause unexpected behavior #1964
Comments
Seems to affect 3.2.5 as well, just wanted to verify: https://runkit.com/bbuck/native-async-functions-in-async-waterfall-pass-undefined |
I also encountered this problem. Using native Async will lose Callback and can only use Promise |
This is expected behavior. The first Or just use await (async fn () {})()
const result = await async.promisify((...args) => {
args.at(-1)(null, args);
}) |
The issue isn't necessarily that async.waterfall(
[
(cb) => { cb(null); },
(...args) => {
args.at(-1)(null, args);
},
],
(error, result) => {
console.log('error', error, '// result', result);
},
); The "return value" passed to that callback function is, implicitly, The output of the above is After all the entire reason I took the time to post this is because I rewrote a "node style" callback to a native async function and then had to debug why I continued to get "undefined is not a function" issues and I'm trying to prevent that from happening to anyone else. |
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. Returningundefined
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.
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.The text was updated successfully, but these errors were encountered: