Skip to content

Commit 7dde0bc

Browse files
committed
Slightly improved error handling.
1 parent d61fb8f commit 7dde0bc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/async/http/protocol/http1/server.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Copyright, 2024, by Anton Zhuravsky.
88

99
require_relative 'connection'
10+
require 'console/event/failure'
1011

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

2426
def next_request
@@ -33,7 +35,7 @@ def next_request
3335
end
3436

3537
return request
36-
rescue Async::TimeoutError
38+
rescue Async::TimeoutError, IO::TimeoutError
3739
# For an interesting discussion about this behaviour, see https://trac.nginx.org/nginx/ticket/1005
3840
# If you enable this, you will see some spec failures...
3941
# fail_request(408)

0 commit comments

Comments
 (0)