Skip to content

Commit 206302b

Browse files
committed
Retry doc downloads on HTTP 5xx errors
1 parent 7a7ee45 commit 206302b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎lib/tasks/docs.thor‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,9 @@ class DocsCLI < Thor
337337
File.write(path, file.read)
338338
end
339339
end
340-
rescue Net::OpenTimeout, Net::ReadTimeout => e
341-
if attempts <= 3
340+
rescue Net::OpenTimeout, Net::ReadTimeout, OpenURI::HTTPError => e
341+
server_error = !e.is_a?(OpenURI::HTTPError) || e.io.status[0].start_with?('5')
342+
if server_error && attempts <= 3
342343
wait_seconds = 2**(attempts - 1)
343344
puts "Docs -- Retrying #{json} in #{wait_seconds}s (#{e.class}: #{e.message})"
344345
sleep(wait_seconds)

0 commit comments

Comments
 (0)