Skip to content

Commit

Permalink
trigger only once
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Jul 22, 2016
1 parent 3bd6223 commit a96710a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/eventDispatcher.js
Expand Up @@ -111,17 +111,21 @@ EventDispatcher.prototype = {
return;
}

var triggered = false;
if (events) {
for (var i = 0, len = events.length; i < len; i++) {
self.undispatchedEventsQueue.push(events[i]);
// If there are a lot of events then we can hit issues with the call stack size when processing in one go
if (i % 1000 === 0){
triggered = true;
trigger(self);
}
}
}

trigger(self);
if (!triggered) {
trigger(self);
}

if (callback) callback(null);
});
Expand Down
2 changes: 1 addition & 1 deletion releasenotes.md
@@ -1,4 +1,4 @@
#### [v1.7.9](https://github.com/adrai/node-eventstore/compare/v1.7.8...v1.7.9)
#### [v1.7.10](https://github.com/adrai/node-eventstore/compare/v1.7.8...v1.7.10)
- This resolves an issue where the maximum call stack size could be hit when processing 1000s of undispatched events on startup [#74](https://github.com/adrai/node-eventstore/pull/74) thanks to [ben-moore](https://github.com/ben-moore)

#### [v1.7.8](https://github.com/adrai/node-eventstore/compare/v1.7.7...v1.7.8)
Expand Down

0 comments on commit a96710a

Please sign in to comment.