I try to get some stats trough my users. Here's how i try to do it :
function(cb) { // Get users count + blocked + Abos
console.log('---- launching count ----');
User.find({pageId: pageId}).exec(function(error, _users) {
if (error) return cb(error);
req._locals.usersCount = _users.length;
console.log('---- userCount:', _users.length, ' ----' );
return cb(_users.map((_user) => {
if (_user.getVariable('tip-subscription-optin') !== null)
req._locals.tipsSubscriptions++;
if (_user.getVariable('tip-mercredi-subscription-optin') !== null)
req._locals.greenSubscriptions++;
}));
});
},
But this isn't working. Here's the error:
---- launching count ----
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
As you can see, my first console.log
is working but not my second. So i'm pretty sure that the mongoose.find
request is too big for my server.