Do no retry web push workers if the server returns a 4xx response (#9434)

Add timeout of 10s to web push requests
This commit is contained in:
Eugen Rochko 2018-12-17 03:14:13 +01:00 committed by GitHub
parent 4297de34cf
commit 628da11e38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -10,8 +10,8 @@ class Web::PushNotificationWorker
notification = Notification.find(notification_id)
subscription.push(notification) unless notification.activity.nil?
rescue Webpush::InvalidSubscription, Webpush::ExpiredSubscription
subscription.destroy!
rescue Webpush::ResponseError => e
subscription.destroy! if (400..499).cover?(e.response.code.to_i)
rescue ActiveRecord::RecordNotFound
true
end