Skip to content

Commit

Permalink
Slightly improved error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 26, 2024
1 parent d61fb8f commit 7dde0bc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/async/http/protocol/http1/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Copyright, 2024, by Anton Zhuravsky.

require_relative 'connection'
require 'console/event/failure'

module Async
module HTTP
Expand All @@ -17,8 +18,9 @@ def fail_request(status)
@persistent = false
write_response(@version, status, {})
write_body(@version, nil)
rescue Errno::ECONNRESET, Errno::EPIPE
# Nothing we can do...
rescue => error
# At this point, there is very little we can do to recover:
Console::Event::Failure.for(error).emit(self, "Failed to write failure response.", severity: :debug)
end

def next_request
Expand All @@ -33,7 +35,7 @@ def next_request
end

return request
rescue Async::TimeoutError
rescue Async::TimeoutError, IO::TimeoutError
# For an interesting discussion about this behaviour, see https://trac.nginx.org/nginx/ticket/1005
# If you enable this, you will see some spec failures...
# fail_request(408)
Expand Down

0 comments on commit 7dde0bc

Please sign in to comment.