Start a new topic

mapReduce within the custom end point started failing with mongoDB internal error

So we have a custom end point that does a mapReduce call and has been working for sometime. I checked today and its failing with a mongoDB internal error. If I pass any variable through scope to the mapReduce function, its doesnt get visible in the mapper function and hence the error. Below is a stripped down code sample to show the problem.



var mapFnV2 = function(){

........

var foo = test; // THIS IS THE ERROR LINE. VAR test IS NOT VISIBLE.

........

emit(strDt, {"data" : value});

};



var reduceFnV2 = function(k, v) {

var reduced = {"data":[]};

......

return reduced;

};



modules.collectionAccess.collection(collectionName)

.mapReduce(mapFnV2,

reduceFnV2,

{ out: {inline:1},

scope: { test: "pankaj"},

query: queryStr,

},

function(err, collection) {

if (err) {

modules.logger.error("mapreduce failed: " + JSON.stringify(err));

return response.error(400);

}

else {

response.body = collection;

return response.complete(200);

}

});



"mapreduce failed: {\"code\":\"MongoError\",\"message\":\"An error has occurred within MongoDB while trying to execute your query\",\"mongoErrorCode\":16722,\"mongoErrorMessage\":\"exception: ReferenceError: test is not defined near 'var foo = test;
1 Comment

Hello,



This was due to a software bug that has now been resolved. We apologize for the inconvenience.
Login or Signup to post a comment