Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add ECONNRESET error as retriable error #20354

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion google-apis-core/lib/google/apis/core/http_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,12 @@ def error(err, rethrow: false, &block)
rescue Google::Apis::Error => e
err = e
end
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)
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) ||
err.is_a?(Errno::ECONNRESET)
err = Google::Apis::TransmissionError.new(err)
end
block.call(nil, err) if block_given?
Expand Down
7 changes: 7 additions & 0 deletions google-apis-core/spec/google/apis/core/http_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,13 @@ class SecretPayload
expect { command.execute(client) }.to raise_error(Google::Apis::TransmissionError)
end

it 'should raise transmission error for broken network connection' do
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_raise(Errno::ECONNRESET)
command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
command.options.retries = 0
expect { command.execute(client) }.to raise_error(Google::Apis::TransmissionError)
end

it 'should raise rate limit error for 429 status codes' do
stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_return(status: [429, ''])
command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
Expand Down
Loading