DEV: Patch capybara to ignore client-triggered errors (#19972)

In dev/prod, these are absorbed by unicorn. Most commonly, they occur when a client interrupts a message-bus long-polling request.

Also reverts the EPIPE workaround introduced in 011c9b9973
This commit is contained in:
David Taylor 2023-01-24 11:07:29 +00:00 committed by GitHub
parent e2db764cdd
commit eee97ad29a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -105,8 +105,6 @@ MessageBus.on_middleware_error do |env, e|
[403, {}, ["Invalid Access"]]
elsif RateLimiter::LimitExceeded === e
[429, { "Retry-After" => e.available_in.to_s }, [e.description]]
elsif Errno::EPIPE === e
[422, {}, ["Closed by Client"]]
end
end

View File

@ -252,6 +252,17 @@ RSpec.configure do |config|
capybara_config.server_port = 31_337 + ENV["TEST_ENV_NUMBER"].to_i
end
module IgnoreUnicornCapturedErrors
def raise_server_error!
super
rescue EOFError, Errno::ECONNRESET, Errno::EPIPE, Errno::ENOTCONN => e
# Ignore these exceptions - caused by client. Handled by unicorn in dev/prod
# https://github.com/defunkt/unicorn/blob/d947cb91cf/lib/unicorn/http_server.rb#L570-L573
end
end
Capybara::Session.class_eval { prepend IgnoreUnicornCapturedErrors }
# The valid values for SELENIUM_BROWSER_LOG_LEVEL are:
#
# OFF