Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-936

Async function usage inside cursor.forEach()/.map() callback does not work properly

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.0.5
    • Affects Version/s: None
    • Component/s: Shell API
    • None
    • Not Needed
    • Iteration Ibadan

      coll = db.getSiblingDB('test').test_coll;
      coll.drop();
      coll.insertOne({ a: 0 });
      print('before')
      coll.find().forEach(() => {
        coll.find().toArray()
        print('inside')
      });
      print('after')
      

      prints

      before
      after
      inside
      

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: