Skip to content

Commit c1ec100

Browse files
feat(core): add ECONNRESET error as retriable error (googleapis#20354)
1 parent 59f3b3a commit c1ec100

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

google-apis-core/lib/google/apis/core/http_command.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,12 @@ def error(err, rethrow: false, &block)
292292
rescue Google::Apis::Error => e
293293
err = e
294294
end
295-
elsif err.is_a?(HTTPClient::TimeoutError) || err.is_a?(SocketError) || err.is_a?(HTTPClient::KeepAliveDisconnected) || err.is_a?(Errno::ECONNREFUSED) || err.is_a?(Errno::ETIMEDOUT)
295+
elsif err.is_a?(HTTPClient::TimeoutError) ||
296+
err.is_a?(SocketError) ||
297+
err.is_a?(HTTPClient::KeepAliveDisconnected) ||
298+
err.is_a?(Errno::ECONNREFUSED) ||
299+
err.is_a?(Errno::ETIMEDOUT) ||
300+
err.is_a?(Errno::ECONNRESET)
296301
err = Google::Apis::TransmissionError.new(err)
297302
end
298303
block.call(nil, err) if block_given?

google-apis-core/spec/google/apis/core/http_command_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,13 @@ class SecretPayload
495495
expect { command.execute(client) }.to raise_error(Google::Apis::TransmissionError)
496496
end
497497

498+
it 'should raise transmission error for broken network connection' do
499+
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_raise(Errno::ECONNRESET)
500+
command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
501+
command.options.retries = 0
502+
expect { command.execute(client) }.to raise_error(Google::Apis::TransmissionError)
503+
end
504+
498505
it 'should raise rate limit error for 429 status codes' do
499506
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_return(status: [429, ''])
500507
command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')

0 commit comments

Comments
 (0)