dns errors: raise error immediately on nxdomain error

no need to loop into candidates.
This commit is contained in:
HoneyryderChuck 2023-04-24 23:08:57 +01:00
parent f56f77d836
commit 04c5b39600
2 changed files with 5 additions and 7 deletions

View File

@ -95,12 +95,12 @@ if RUBY_VERSION >= "2.4.0"
response = HTTPX.get(uri)
verify_error_response(response, /Can't resolve unexisting/)
verify_error_response(response, /name or service not known/)
assert response.is_a?(HTTPX::ErrorResponse), "response should contain errors"
verify_spans(transaction, response, verb: "GET")
crumb = Sentry.get_current_scope.breadcrumbs.peek
assert crumb.category == "httpx"
assert crumb.data == { error: "Can't resolve unexisting", method: "GET", url: uri.to_s }
assert crumb.data == { error: "name or service not known (unexisting)", method: "GET", url: uri.to_s }
end
private

View File

@ -244,12 +244,10 @@ module HTTPX
when :no_domain_found
# Indicates no such domain was found.
hostname, connection = @queries.first
reset_hostname(hostname, reset_candidates: false)
reset_hostname(hostname)
unless @queries.value?(connection)
@connections.delete(connection)
raise NativeResolveError.new(connection, connection.origin.host)
end
@connections.delete(connection)
raise NativeResolveError.new(connection, connection.origin.host, "name or service not known (#{hostname})")
when :message_truncated
# TODO: what to do if it's already tcp??
return if @socket_type == :tcp