When promisifying the mongodb driver module, I can insert multiple documents to a collection successfully. However, I'm also getting a stack_overflow Error hitting the catch block.
My approach is based on the answer to this question: Mongodb node driver 2.0.* with Bluebird 2.9.* promisification
I'm promisifying mongodb like this:
var Promise = require('bluebird'),
mongodb = Promise.promisifyAll(require('mongodb'));
My code looks like this:
mongodb.connectAsync("mongodb://myconnection").then(function(db) {
return db.collection("collection").insertManyAsync([{a: 1}, {b: 2}]);
}).then(function(result) {
console.log('info', result);
}).catch(function(err) {
console.log('error', err);
});
The error caught in the catch block (after then(function(result{})
has been executed every time) has type "stack_overflow".
I tried using just the insert method (insertAsync()
in this case), but that has the same results.