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

A solution for stoping a flow after an early exit #1064

Closed
herobs opened this issue Mar 15, 2016 · 12 comments · Fixed by #1542
Closed

A solution for stoping a flow after an early exit #1064

herobs opened this issue Mar 15, 2016 · 12 comments · Fixed by #1542
Assignees
Milestone

Comments

@herobs
Copy link

herobs commented Mar 15, 2016

There are a strong requirement that stop a flow normally instead of call callback with a fake err. I find a solution from restify:

You can pass in false to not error, but to stop the handler chain.

So only null to indicate a error, and false for normal terminal.

callback(false) will stop the flow, but won't active error handle like if (err) console.log(err).

@aearly
Copy link
Collaborator

aearly commented Mar 15, 2016

Hmnn, this is very intriguing! I like that there is precedent in restify. It also seems like false might be a good value to use -- most people pass null or undefined. There is a bit of symmetry with how returning false in _.each also breaks the iteration.

@aearly aearly changed the title Maybe a solution for stop a flow normally A solution for stoping a flow after an early exit Mar 21, 2016
@aearly
Copy link
Collaborator

aearly commented Mar 30, 2016

@megawac What do you think about this?

@megawac
Copy link
Collaborator

megawac commented Mar 30, 2016

Works for me (in a major bump) - would be nice for the createTester
implementation as it will have an improved method of terminating *Series
and *Limit based iteration

On Wed, Mar 30, 2016 at 2:58 PM, Alex Early notifications@github.com
wrote:

@megawac https://github.com/megawac What do you think about this?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1064 (comment)

@aearly
Copy link
Collaborator

aearly commented Apr 4, 2016

Yeah, I agree, we should save it for the next major. The breaking change we made with predicate-style functions (e.g. some, filter) would make this change cause extra confusion as people migrate since people would be passing false as the first arg.

@aearly aearly added this to the 3.0 milestone Apr 4, 2016
@wilfredjonathanjames
Copy link

Not having this is very inconvenient. I support the use of cb(false) - it's what I had expected to exist when first using this module.

@megawac
Copy link
Collaborator

megawac commented Oct 4, 2016

Think I will be hammering on some of these breaking changes over the weekend.

@hargasinski @aearly any thoughts on a 3.0 timeline? December perhaps?

@aearly
Copy link
Collaborator

aearly commented Oct 4, 2016

Do we have any stats on how widely used v2 is? I wouldn't want to have more breaking changes for people to evaluate while most people still haven't upgraded.

@hargasinski
Copy link
Collaborator

We should probably do a minor 2.1 release with the changes applied in #1261 and a non-breaking fix for #1293 before 3.0. The docs will also get updated with the changes in PRs, such as #1263, #1271, and #1280, which will be helpful.

@aearly, that's good point. 2.0 will have been released for 6 months in December. Should we assume that will be enough time for most users to update? We could use the changelog to write a migration guide in the Wiki for 1.5 to 3.0.

@megawac
Copy link
Collaborator

megawac commented Oct 17, 2016

This is now somewhat possible with 2.1.1 by returning async/internal/breakLoop

@stephent
Copy link

@megawac is there a link to any documentation for this (async/internal/breakLoop)? Not seeing anything on the site so far.

@aearly
Copy link
Collaborator

aearly commented Oct 18, 2016

I'd be hesitant to use it, as we are not fully decided that this is how we want to handle early exits. We could change this later, breaking your code.

@aearly
Copy link
Collaborator

aearly commented Apr 7, 2017

https://libraries.io has some great version stats: https://libraries.io/npm/async/usage

I broke down the percent of </> v2.x here 📈

20% of dependents are v2.0+. (v1.5.2 is our most widely used version, though, ~22%). v2.0 has been in the wild for a year. I think we can start thinking about v3.

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

Successfully merging a pull request may close this issue.

6 participants