Skip to content
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

Undocumented breaking change (now incompatible with caolan/async) #91

Open
mathiasm74 opened this issue Oct 14, 2020 · 1 comment
Open

Comments

@mathiasm74
Copy link

The code below works with caolan/async v3.2.0 and with suguru03/neo-async v1.8.2 and outputs

Arguments passed from 'each()' callback: [Arguments] { '0': [Function] }
Arguments passed from 'waterfall()' callback: [Arguments] { '0': null }

However after updating suguru03/neo-async to v2.6.2 it will crash, and only work if the "res" argument is added to the "step2" function. The output is now different:

Arguments passed from 'each()' callback: [Arguments] { '0': undefined, '1': [Function: next] }
Arguments passed from 'waterfall()' callback: [Arguments] { '0': null, '1': undefined }

It appears this breaking changes was introduced by the new once() methods in

commit bd0fb377579bcd83b7ef5b155bf55668c6b4788f
Author: Suguru Motegi <[email protected]>
Date:   Sat Sep 29 19:49:26 2018 -0700

and the original behaviour seems to be correct and desired, since the new argument is always 'undefined'.

Here's the test code:

const order = [];
const array = [1, 3, 2];

async.waterfall([
  function step1(callback) {
    async.each(
      array, 
      function iterator(num, done) {
        setTimeout(function() {
          order.push(num);
          done();
        }, num * 10);
      }, 
      callback
    );
  },
  function step2(/*res, */callback) {
    console.log("Arguments passed from 'each()' callback:", arguments);
    callback(null);
  }
], function done(err) {
  console.log("Arguments passed from 'waterfall()' callback:", arguments);
  process.exit();
});
@suguru03
Copy link
Owner

@mathiasm74
Thanks for the issue!

I would like to fix it, however, the fix would affect a lot of users… so I will fix it on the next major update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants