Skip to content

Commit f1171bb

Browse files
committed
add new EdgeThrottled exception
Edge throttles *much* more aggressively than other browsers, added a new ResponseError subclass called EdgeThrottled and added code to verify_response to distinguish this case from a generic ResponseError. I'd still like to know if I ever get throttled by Chrome, Firefox, or Safari since it's never happened before, but it happens so much with Edge that I've just given up and ignore these exceptions personally. Others may want to handle this specific case differently as well.
1 parent 5372677 commit f1171bb

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/web_push/errors.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ class PayloadTooLarge < ResponseError; end
2626
class TooManyRequests < ResponseError; end
2727

2828
class PushServiceError < ResponseError; end
29+
30+
class EdgeThrottled < ResponseError; end
2931
end

lib/web_push/request.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ def verify_response(resp)
147147
elsif resp.is_a?(Net::HTTPUnauthorized) || resp.is_a?(Net::HTTPForbidden) || # 401, 403
148148
resp.is_a?(Net::HTTPBadRequest) && resp.message == 'UnauthorizedRegistration' # 400, Google FCM
149149
raise Unauthorized.new(resp, uri.host)
150+
elsif resp.is_a?(Net::HTTPNotAcceptable) && uri.host.to_s.ends_with?("notify.windows.com") #406 on Edge
151+
raise EdgeThrottled.new(resp, uri.host)
150152
elsif resp.is_a?(Net::HTTPRequestEntityTooLarge) # 413
151153
raise PayloadTooLarge.new(resp, uri.host)
152154
elsif resp.is_a?(Net::HTTPTooManyRequests) # 429, try again later!

0 commit comments

Comments
 (0)