Skip to content
This repository was archived by the owner on May 3, 2023. It is now read-only.

Commit 49a9950

Browse files
authored
Adding retry for error 500 (#158)
1 parent c31ae37 commit 49a9950

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/autoprovision/auth_helper.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,19 @@ def get_developer_portal_data(build_url, build_api_token)
4646
http_object = Net::HTTP.new(uri.host, uri.port)
4747
http_object.use_ssl = true
4848

49-
response = http_object.start do |http|
50-
http.request(request)
49+
response = nil
50+
4.times do |i|
51+
response = http_object.start do |http|
52+
http.request(request)
53+
end
54+
55+
if response == Net::HTTPServerError
56+
Log.debug("Request failed, retrying. (response: #{response})")
57+
sleep(i**2)
58+
next
59+
end
60+
61+
break
5162
end
5263

5364
raise 'failed to get response' unless response

0 commit comments

Comments
 (0)