Increase the max number of model listeners

See https://github.com/strongloop/loopback/issues/404
This commit is contained in:
Raymond Feng 2014-07-28 13:02:00 -07:00
parent 5221d12305
commit 8bc11ca51e
1 changed files with 3 additions and 0 deletions

View File

@ -161,6 +161,9 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett
};
// mix in EventEmitter (don't inherit from)
var events = new EventEmitter();
// The model can have more than 10 listeners for lazy relationship setup
// See https://github.com/strongloop/loopback/issues/404
events.setMaxListeners(32);
for (var f in EventEmitter.prototype) {
if (typeof EventEmitter.prototype[f] === 'function') {
ModelClass[f] = EventEmitter.prototype[f].bind(events);