Comparing version 1.3.7 to 1.3.8
## Changelog | ||
1.3.8: | ||
* Notifications now have a configurable number of retries. See `Notification.retryLimit` in docs. | ||
* Fixed: Error wasn't raised on notifications if the module fails to initialise, they just perpetually lived on the queue. | ||
1.3.7: | ||
@@ -4,0 +9,0 @@ |
@@ -214,2 +214,10 @@ var Errors = require('./errors'); | ||
debug("Module initialisation error:", error); | ||
// This is a pretty fatal scenario, we don't have key/certificate to connect to APNS, there's not much we can do, so raise errors and clear the queue. | ||
while(this.notificationBuffer.length > 0) { | ||
var notification = this.notificationBuffer.shift(); | ||
this.raiseError(error, notification.notification, notification.recipient); | ||
this.emit('transmissionError', Errors['moduleInitialisationFailed'], notification.notification, notification.recipient); | ||
} | ||
this.raiseError(error); | ||
this.emit('error', error); | ||
@@ -404,2 +412,8 @@ this.deferredConnection.reject(error); | ||
Connection.prototype.bufferNotification = function (notification) { | ||
if (notification.retryLimit === 0) { | ||
this.raiseError(Errors['retryCountExceeded'], notification); | ||
this.emit('transmissionError', Errors['retryCountExceeded'], notification.notification, notification.recipient); | ||
return; | ||
} | ||
notification.retryLimit -= 1; | ||
this.notificationBuffer.push(notification); | ||
@@ -436,3 +450,3 @@ }; | ||
} | ||
this.bufferNotification( { "notification": notification, "recipient": recipient } ); | ||
this.bufferNotification( { "notification": notification, "recipient": recipient, "retryLimit": notification.retryLimit } ); | ||
}; | ||
@@ -439,0 +453,0 @@ |
@@ -17,5 +17,7 @@ /** | ||
'apnsShutdown': 10, | ||
'none': 255 | ||
'none': 255, | ||
'retryLimitExceeded': 512, | ||
'moduleInitialisationFailed': 513 | ||
}; | ||
module.exports = Errors; |
@@ -12,2 +12,4 @@ /** | ||
this.retryLimit = -1; | ||
/** @deprecated since v1.3.0 used connection#pushNotification instead which accepts device token separately **/ | ||
@@ -14,0 +16,0 @@ this.device = undefined; |
{ | ||
"name": "apn", | ||
"description": "An interface to the Apple Push Notification service for Node.js", | ||
"version": "1.3.7", | ||
"version": "1.3.8", | ||
"author": "Andrew Naylor <argon@mkbot.net>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
Sorry, the diff of this file is not supported yet
103149
1258