mongodb - Mongoose silent crash in Node.js -


i'm trying insert bulk of plain objects mongodb, weird happening. let's try insert 1000 objects this

for (var = 0; < 1000; i++) {      var commentaux = {        'a': 'test' + i,        'b': 'https://test.com',        'c': appuser.id,        'd': 'test of' +      }      comments.push(commentaux); } comment.collection.insert(comments, function (err, docs) {    if (err) {      return res.json({success: false, message: 'comments fail'});    } } 

but if change 1000 lets 1500, server hangs. never throws excetpion, neither warning, nothing. stucks there. i've been reading, , amount of documents isn't near limit amount mongo supports.

someone face same issue? i'm using mongo 3.2 in windows

as mentioned in comments, bulk max size 1000...so i've implemented custom bulkmanager in order manage high amounts of documents in api.

so bulkmanager.js this.

module.exports = function () {     var instance = {};     var promise = require("bluebird");     var q = require("q");     promise.promisifyall(instance);      instance.insert = function (dbmodel, items) {         var arrays = [], size = 1000;          while (items.length > 0)             arrays.push(items.splice(0, size));          return saveitems(dbmodel, arrays, arrays.length, 0);     };      var deferred = q.defer();      function saveitems(dbmodel, arrays, amounttoprocess, indextoprocess) {         if (indextoprocess <= (amounttoprocess - 1)) {             var items = arrays[indextoprocess];             dbmodel.collection.insert(items, function (err, docs) {                 if (err) {                     return deferred.reject({success: false, error: err});                 }                  if (amounttoprocess > 1 && indextoprocess < (amounttoprocess - 1)) {                     indextoprocess++;                     saveitems(dbmodel, arrays, amounttoprocess, indextoprocess);                 } else {                     return deferred.resolve({success: true, docs: docs});                 }             });         }         return deferred.promise;     }     return instance; }; 

and api call this.

bulkmanager.insert(photomodel, photos).then(function (response) {     if (!response.success) {         return res.json({success: false, message: 'photos fail'});     }     // stuff on success } 

Comments