diff --git a/lib/helpers/populate/markArraySubdocsPopulated.js b/lib/helpers/populate/markArraySubdocsPopulated.js index 28b19a1989a..a22605a1d78 100644 --- a/lib/helpers/populate/markArraySubdocsPopulated.js +++ b/lib/helpers/populate/markArraySubdocsPopulated.js @@ -38,7 +38,9 @@ module.exports = function markArraySubdocsPopulated(doc, populated) { if (utils.isMongooseDocumentArray(val)) { for (let j = 0; j < val.length; ++j) { - val[j].populated(rest, item._docs[id] == null ? void 0 : item._docs[id][j], item); + if(val[j]){ + val[j].populated(rest, item._docs[id] == null ? void 0 : item._docs[id][j], item); + } } break; }