hivewallet / hive-js

Hive digital currency wallet
http://www.hivewallet.com
GNU General Public License v2.0
81 stars 57 forks source link

Strange event emitter error #100

Closed haustraliaer closed 10 years ago

haustraliaer commented 10 years ago

While clicking around the auth section (more than necessary as I was testing button states) I came across this odd error in the console:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.

Cannot reproduce :/

mattlenz commented 10 years ago

Found a way to reproduce this, and have a thought on a fix

emitter

As you can see from my console, the wallet-opening event is being bound over and over again. We need to unbind this event when the view changes (not sure how to do this in ractive)

mattlenz commented 10 years ago

FYI I monkey-patched the emitter to give me some hints

var Emitter = require('events').EventEmitter

var emitter = new Emitter()

emitter._off = emitter.off
emitter._on = emitter.on

emitter.on = function() {
  console.log('Bound', arguments)
  this._on.apply(this, arguments)
}

emitter.off = function() {
  console.log('Unbound', arguments)
  this._off.apply(this, arguments)
}

module.exports = emitter