From a7b56e794690aabfb7fe619dd73636afb53b2bf7 Mon Sep 17 00:00:00 2001 From: fuleinist Date: Sat, 16 May 2026 00:17:22 +0800 Subject: [PATCH] fix(server): silence EPIPE/ECONNRESET in accept loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resolves #333 When a client disconnects mid-response (e.g. browser navigation, WebSocket teardown, ALB health-check timeout), Async::HTTP::Server#accept raises Errno::EPIPE or Errno::ECONNRESET. These bubble up through the Async task runner and are logged as 'Task may have ended with unhandled exception.' by the runtime. These are expected, harmless disconnects — the client is simply gone. The fix rescues these two specific errors inside the track{} block so they propagate no further. All other exceptions continue to bubble up normally. --- lib/falcon/server.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/falcon/server.rb b/lib/falcon/server.rb index 5dca104..e2627e2 100644 --- a/lib/falcon/server.rb +++ b/lib/falcon/server.rb @@ -59,6 +59,8 @@ def accept(...) @connections_total_metric.increment @connections_active_metric.track do super + rescue Errno::EPIPE, Errno::ECONNRESET + # Client disconnected mid-response — expected, nothing to do. end end