I am getting the following error:
(node:18591) MaxListenersExceededWarning: Possible EventEmitter memory
leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit.
after a script for sending push notifications is executed. I am using "node-gcm" and "apn" npm modules for sending android and ios push notifications respectively. Code that I am using for sending notifications is:
Android:
async.each(tokenBatches, function (batch) {
// Assuming you already set up the sender and message
sender.send(message, {registrationIds: batch}, function (err, result) {
// Push failed?
if (err) {
// Stops executing other batches
console.log(err);
}
console.log(result);
});
});
Here, device tokens are passed as a batch of 1000 tokens.
IOS:
provider.send(notification, iosTokens).then((response) => {
console.log(response);
});
Here, all tokens are sent inside the iosTokens array. These two scripts are run in parallel. What could be wrong in this code? I saw some solutions asking to set max listeners, but I am not getting it right. Is there any way to fix the memory leak error. Any help would be appreciated! Thanks in advance.