MaxListenersExceededWarning - Loopback

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 the script to send push notifications. I am using "node-gcm" and "apn" npm modules to send android and ios push notifications respectively. The code I'm using to send notifications:

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 transferred 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 run in parallel. What could be wrong with this code? I've seen some solutions suggesting to set the maximum number of listeners, but I don't get it. Is there any way to fix the memory leak error. Any help would be appreciated! Thanks in advance.

+3


source to share





All Articles