-
Type: Bug
-
Resolution: Cannot Reproduce
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.1.10
-
Component/s: None
-
Labels:
-
Empty show more show less
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() }