You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
var size = object.length || _keys(object).length;
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, so size ends up being 33.
but then on iteration in _each the function isArrayLike returns true 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
var size = isArrayLike(object) ? object.length : _keys(object).length;
The text was updated successfully, but these errors were encountered:
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: