Permalink
Browse files

Added a check to ensure the error handling doesn't fail when there ar…

…e no cached notifications.
  • Loading branch information...
1 parent 598fadb commit cee13fd55a3c46b966c0f10960e84e641fd27904 @argon argon committed Nov 29, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/connection.js
View
@@ -337,10 +337,12 @@ Connection.prototype.handleTransmissionError = function (data) {
else {
this.cachedNotifications = temporaryCache;
- var differentialSize = this.cachedNotifications[0]['_uid'] - notification['_uid']
- this.emit('cacheTooSmall', differentialSize);
- if(this.options.autoAdjustCache) {
- this.options.cacheLength += differentialSize * 2;
+ if(this.cachedNotifications.length > 0) {
+ var differentialSize = this.cachedNotifications[0]['_uid'] - notification['_uid']
+ this.emit('cacheTooSmall', differentialSize);
+ if(this.options.autoAdjustCache) {
+ this.options.cacheLength += differentialSize * 2;
+ }
}
this.emit('transmissionError', Errors["none"], null);

0 comments on commit cee13fd

Please sign in to comment.