Skip to content

Commit

Permalink
fix(model): avoid uncaught error if insertMany() fails due to serve…
Browse files Browse the repository at this point in the history
…r selection error

Fix #9355
  • Loading branch information
vkarpov15 committed Aug 28, 2020
1 parent 9f2ebdb commit 648e6e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3323,7 +3323,7 @@ Model.$__insertMany = function(arr, options, callback) {
}

// `insertedDocs` is a Mongoose-specific property
const erroredIndexes = new Set(error.writeErrors.map(err => err.index));
const erroredIndexes = new Set(get(error, 'writeErrors', []).map(err => err.index));
error.insertedDocs = docAttributes.filter((doc, i) => {
return !erroredIndexes.has(i);
});
Expand Down

0 comments on commit 648e6e6

Please sign in to comment.