0

经过大量的努力和谷歌搜索,我仍然无法弄清楚如何解决这个问题。需要帮助请...

输出:

    (node) warning: possible EventEmitter memory leak detected. 51 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at EventEmitter.addListener (events.js:160:15)
    at EventEmitter.once (events.js:179:8)
    at SkinCollection.open (/home/nitin/node_modules/mongoskin/lib/mongoskin/collection.js:108:20)
    at obj.(anonymous function) [as insert] (/home/nitin/node_modules/mongoskin/lib/mongoskin/utils.js:64:10)
    at insertErrorLog (/home/nitin/dev/aayush/errorLog.js:37:18)
    at Server.<anonymous> (/home/nitin/dev/aayush/errorLog.js:69:24)
    at Server.EventEmitter.emit (events.js:98:17)
    at HTTPParser.parser.onIncoming (http.js:2022:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:119:23)
    at Socket.socket.ondata (http.js:1912:22)

代码链接:代码链接

提前Thnax寻求帮助...

4

1 回答 1

0

每当您调用它时,它看起来db.collection都会创建一个 EventEmitter。您是否应该尝试在请求处理程序之外缓存集合:

var logs = db.collection('logs');

var insertErrorLog = function (req, res) {
  var pathname = url.parse(req.url).pathname;
  var ua = req.headers['user-agent'];     // user-agent header from an HTTP request
  var details = parser.setUA(ua).getResult();
  var params = url.parse(req.url,true).query;

  logs.insert({…});

快速查看代码表明它应该始终返回相同的实例,但我看不出您的问题的任何其他原因:

https://github.com/kissjs/node-mongoskin/blob/master/lib/mongoskin/db.js#L148

于 2013-09-17T13:05:52.207 回答