I have been using a mapReduce for some time now to check all possible keys in my collections. This used to work fine, until now. All of a sudden (After upgrading to 1.4.2.3, although going back to 1.4.2.1 is now the same) I am getting the following error:
Exception while invoking method 'scan.features' MongoError: ReferenceError: meteorBabelHelpers is not defined :
at Object.Future.wait (/Users/rensholmer/.meteor/packages/meteor-tool/.1.4.2_3.1ib5jxz++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:449:15)
at [object Object].scanFeatures (server/methods.js:178:32)
<<<etc. etc.>>>
I have highlighted the offending line from my methods below, along with the method I am using for the mapReduce:
Meteor.methods({
'scan.features':function(){
this.unblock();
//meteor requires async code to be run in a fiber/future
const fut = new Future();
//put the future that will hold the mapreduce output in the meteor environment, this will be used as callback for the mapreduce
const mapReduceCallback = Meteor.bindEnvironment(function(err,res){
if (err){
fut.throw(err)
} else {
fut.return(res)
}
}
)
//mapreduce to find all keys for all genes, this takes a while
a = Items.rawCollection().mapReduce(
function(){
//map function
for (var key in this){
emit(key,null)
}
},
function(key,values){
//reduce function
return null
},
{ out: { inline: 1 } }, //output options
mapReduceCallback
)
//let the future wait for the mapreduce to finish
const mapReduceResults = fut.wait(); //<-------- OFFENDING LINE
//process mapreduce output and put it in a collection
mapReduceResults.forEach(function(i){
FilterOptions.findAndModify({
query: { ID: i._id },
update: { $setOnInsert: { name: i._id, show: true, canEdit: false } },
new: true,
upsert: true
})
})
//add the viewing and editing option, since this key is dynamic it will not allways be present on any Item, but we do want to filter on this
const permanentOptions = ['viewing','editing']
permanentOptions.forEach(function(optionId){
FilterOptions.findAndModify({
query: { ID: optionId },
update: { $setOnInsert: { name: optionId, show: true, canEdit: false } },
new: true,
upsert: true
})
})
}
})
I have tried wrapping everything in Meteor.wrapAsync(), and I get the same error when executing the wrapped function.
As usual, any feedback is welcome!