小编Pho*_*Dev的帖子

MaxListenersExceededWarning - 环回

我收到以下错误:

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

在执行发送推送通知的脚本之后。我正在使用“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);
    });
});
Run Code Online (Sandbox Code Playgroud)

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

IOS:

provider.send(notification, iosTokens).then((response) => {
   console.log(response);
});
Run Code Online (Sandbox Code Playgroud)

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

memory-leaks node.js loopbackjs node-apn node-gcm

5
推荐指数
0
解决办法
1791
查看次数

如何在环回中执行原始 mongodb 查询

如何在环回远程方法中执行原始 mongo db 查询?我试过:

    Members.getDataSource().connector.connect(function (err, db) {
          var collection = db.collection('Members');
          var res = collection.find();
          console.log(res);
   });
Run Code Online (Sandbox Code Playgroud)

在这里, res 为我提供了一个对象内的大量数据,但我无法从该对象中找到任何结果文档。任何帮助将不胜感激!谢谢 !

mongodb node.js loopbackjs

3
推荐指数
1
解决办法
2520
查看次数

标签 统计

loopbackjs ×2

node.js ×2

memory-leaks ×1

mongodb ×1

node-apn ×1

node-gcm ×1