Skip to content

Commit

Permalink
Prevent whole server crash on MPNS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Poitrey committed Jun 12, 2013
1 parent c2544f6 commit 571c2ea
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/pushservices/mpns.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ class PushServiceMPNS
@logger?.error("Unsupported MPNS notification type: #{@conf.type}")

if sender
sender info.token, note, (error, result) =>
if error
if error.shouldDeleteChannel
@logger?.warn("MPNS Automatic unregistration for subscriber #{subscriber.id}")
subscriber.delete()
try
sender info.token, note, (error, result) =>
if error
if error.shouldDeleteChannel
@logger?.warn("MPNS Automatic unregistration for subscriber #{subscriber.id}")
subscriber.delete()
else
@logger?.error("MPNS Error: (#{error.statusCode}) #{error.innerError}")
else
@logger?.error("MPNS Error: (#{error.statusCode}) #{error.innerError}")
else
@logger?.verbose("MPNS result: #{JSON.stringify result}")
@logger?.verbose("MPNS result: #{JSON.stringify result}")
catch error
@logger?.error("MPNS Error: #{error}")

exports.PushServiceMPNS = PushServiceMPNS

0 comments on commit 571c2ea

Please sign in to comment.