我在相当多的Node.js库中看到这种模式: Master.prototype.__proto__ = EventEmitter.prototype; (来源于此 ) 有人可以给我解释一下,为什么这是一个普遍的模式,什么时候方便?
我收到以下警告: (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. Trace: at EventEmitter.<anonymous> (events.js:139:15) at EventEmitter.<anonymous> (node.js:385:29) at Server.<anonymous> (server.js:20:17) at Server.emit (events.js:70:17) at HTTPParser.onIncoming (http.js:1514:12) at HTTPParser.onHeadersComplete (http.js:102:31) at Socket.ondata (http.js:1410:22) at TCP.onread (net.js:354:27) 我在server.js中写这样的代码: http.createServer( function (req, res) { … }).listen(3013); 如何解决这个问题?
我怎样才能debugging我的应用程序引发这个错误: (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. Trace at Socket.EventEmitter.addListener (events.js:160:15) at Socket.Readable.on (_stream_readable.js:653:33) at Socket.EventEmitter.once (events.js:179:8) at TCP.onread (net.js:527:26) 我无法find假设的泄漏对象,以增加侦听器限制,通过.setMaxListeners(0); 解决scheme(来自fardjad和jan salawa) 随着jan salawa的search,我发现了一个工作库( longjohn ),用于增加堆栈跟踪详细信息。 随着fardjad的回应,我发现我们必须原型EventEmitter.addListener 和 EventEmitter.on 。 有了解决scheme,我可以得到这个新的痕迹: (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase […]