title: forEach doesn't iterate all collection in mongodb
body: <p>I need to compare two collections of objects from mongo db.
  My shell script looks like this:</p>
  
  <pre><code>//Both arrays have 367 pretty big objects.
  var list1 = db.collection1.find({..condition..}).toArray(); 
  var list2 = db.collection2.find({..condition..}).toArray();
  
  function compare(left, right){
     var l = left.data.NP;
     var r = right.data.NP;
     if(JSON.stringify(l) === JSON.stringify(r)){
        return 'Equal';
     } else {
        return 'Not equal';
     }
  }
  
  list1.forEach(function(item, index){
     print(index, compare(item,list2[index]));
  })
  </code></pre>
  
  <p>I execute this script in the Robomongo.
  But i have a problem. At the result only 8 items from 367 was printed. Robomongo didn't show any error messages.
  When i used </p>
  
  <pre><code>print(item);
  </code></pre>
  
  <p>inside foreach, all worked fine and all 367 objects was printed. Also i tried to use Deep Diff library for objects comparison but got same result - only 12 items from 367 was printed.</p>
  
  <p>I think the problem in the memory consumption, but i don't know how to handle it, and why Robomongo doesn't print any errors.</p>
  
  <p>I tried to iterate only cursors but it didn't help.</p>
  
  <p>Why foreach could iterate not all items and how to fix it ?</p>
  
  <p><strong>[UPDATE 1]</strong>
  After some time of the investigation i mentioned that if i run script in just opened tab in Robomongo it prints 102 elements, but when i run it again in the same tab it prints only 12.</p>
  
  <p><strong>[UPDATE 2]</strong>
  I tried to run script using native mongo shell mongo.exe and got 100 from 367 elements printed, without errors</p>