From d3f400f525320529005acad0c0c682a080311c95 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Thu, 2 Apr 2026 01:28:29 +0900 Subject: [PATCH] Use `rescue StandardError` for stream close ## Motivation and Context Replace bare `rescue` with explicit `rescue StandardError` in stream cleanup to clarify intent, with a comment explaining why. In Ruby, `rescue` without an exception class is equivalent to `rescue StandardError`, so this is a readability improvement with no behavior change. ## How Has This Been Tested? Existing tests pass. ## Breaking Changes None. --- lib/mcp/server/transports/streamable_http_transport.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mcp/server/transports/streamable_http_transport.rb b/lib/mcp/server/transports/streamable_http_transport.rb index 4e014586..c2efc2c1 100644 --- a/lib/mcp/server/transports/streamable_http_transport.rb +++ b/lib/mcp/server/transports/streamable_http_transport.rb @@ -150,8 +150,8 @@ def reap_expired_sessions # removed from `@sessions` above, so other threads will not find them # and will not attempt to close the same stream. stream.close - rescue - nil + rescue StandardError + # Ignore close-related errors from already closed/broken streams. end end @@ -239,8 +239,8 @@ def cleanup_session_unsafe(session_id) begin session[:stream]&.close - rescue - nil + rescue StandardError + # Ignore close-related errors from already closed/broken streams. end @sessions.delete(session_id) end