Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

"completed" counter issue with async.forEach #121

Closed
wants to merge 1 commit into from

2 participants

Derek Kastner Caolan McMahon
Derek Kastner

An issue appears in Chrome (but not node) where the completed counter goes above the array length on a forEach. Somehow the === comparison between completed and arr.length is failing.

Not sure the exact cause and I had trouble coming up with a test to reproduce, but thought I'd throw it out there for your consideration.

Derek Kastner dkastner Use a more "liberal" loop counter
An issue appears in Chrome (but not node)
where the completed counter goes above the
array length on a forEach. Somehow the ===
comparison between completed and arr.length
is failing.
7d6f5c9
Caolan McMahon caolan closed this in f839572
Caolan McMahon
Owner

That sounds very odd, but the fix seems equally correct as a strict equals check, so happy to accept it instead of wondering why the rest of the world, and Chrome in particular, is not behaving as it should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 17, 2012
  1. Derek Kastner

    Use a more "liberal" loop counter

    dkastner authored
    An issue appears in Chrome (but not node)
    where the completed counter goes above the
    array length on a forEach. Somehow the ===
    comparison between completed and arr.length
    is failing.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/async.js
4 lib/async.js
View
@@ -90,7 +90,7 @@
}
else {
completed += 1;
- if (completed === arr.length) {
+ if (completed >= arr.length) {
callback();
}
}
@@ -112,7 +112,7 @@
}
else {
completed += 1;
- if (completed === arr.length) {
+ if (completed >= arr.length) {
callback();
}
else {
Something went wrong with that request. Please try again.