5

我收到以下错误:

 (node:18591) MaxListenersExceededWarning: Possible EventEmitter memory 
leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit.

在执行发送推送通知的脚本之后。我正在使用“node-gcm”和“apn”npm 模块分别发送 android 和 ios 推送通知。我用于发送通知的代码是:

安卓:

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);
    });
});

在这里,设备令牌作为一批 1000 个令牌传递。

IOS:

provider.send(notification, iosTokens).then((response) => {
   console.log(response);
});

在这里,所有令牌都在 iosTokens 数组中发送。这两个脚本并行运行。这段代码可能有什么问题?我看到一些解决方案要求设置最大听众,但我没有做对。有什么办法可以解决内存泄漏错误。任何帮助,将不胜感激!提前致谢。

4

0 回答 0