-
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
async.each with empty MongooseArray never calls final callback #775
Labels
Comments
Good catch. A PR with a regression test would be welcome! Otherwise I'll get to this later today. |
ok, will submit PR |
PR see #777 |
Thanks for your help! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We just tried to update async, mongoose and io.js and noticed a problem with async.forEach hanging when we pass a Mongoose Array of length 0. The following code leads to the problems:
lib/async.js:224
the object.length is 0 because we have an empty Array, and 0 evaluates to
falsy
, but then mongoose attaches properties to the Array Object, so _keys(object).length returns 33, sosize
ends up being 33.but then on iteration in
_each
the functionisArrayLike
returnstrue
so it uses_arrayEach
to iterate, but there are no entries to iterate because object.length is 0, so the final callback is never called, the 33 properties are never iterated.This seems inconsistent. I think a correct fix would be to use the isArrayLike in both places:
lib/async.js:224
The text was updated successfully, but these errors were encountered: