Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1819

bulk.execute() inserts data to DB but promise is un resolved and un-rejected i.e. no bulkWriteResult or bulkWriteError is returned

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.1.10
    • Component/s: None
    • Labels:

      Hi, we've recently upgraded from mongoDB driver 2.2.34 to 3.1.10, we have a function which performs a bulk.execute() for some documents to be inserted into the DB.

       

      What we expect is the insert to complete with bulkWriteResult or bulkWriteError responses returned however what we're finding is the inserts are going into the DB but the promise doesn't resolve or reject as no result or error objects are returned hence we suspect it could be a bug. Have tried adding `return bulk.execute().then(console.log)` to confirm the result but as it never resolves the .then() is never reached.

       

      This function was working correctly prior to the upgrade, downgrading isn't a likely option for us but this is really preventing us from working. 

       

      Any insights?

       

      Here is the function in question, it takes 3 parameters, database = the MongoClient, collectionName = collectionName in question, documents = array of valid documents to be inserted into the DB. 

       const insertManyMissingEntries = (database, collectionName, documents) => {
        const db = database.db('data')
        const collection = db.collection(collectionName)
        const batch = collection.initializeUnorderedBulkOp()
        documents.forEach(doc => {
          batch
            .find({ year: doc.year, month: doc.month, code: doc.code })
            .upsert()
            .updateOne({ '$setOnInsert': doc })
        })
      
        return batch.execute()
      }
      
      

            Assignee:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Reporter:
            sbwork Scott Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: