Skip to content

Commit 7954cfd

Browse files
committed
Use rescue StandardError for stream close
## Motivation and Context Replace bare `rescue` with explicit `rescue StandardError` in stream cleanup to clarify intent. 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 will pass. ## Breaking Changes None.
1 parent 5631990 commit 7954cfd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/mcp/server/transports/streamable_http_transport.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ def reap_expired_sessions
150150
# removed from `@sessions` above, so other threads will not find them
151151
# and will not attempt to close the same stream.
152152
stream.close
153-
rescue
154-
nil
153+
rescue StandardError
154+
# Ignore close-related errors from already closed/broken streams.
155155
end
156156
end
157157

@@ -239,8 +239,8 @@ def cleanup_session_unsafe(session_id)
239239

240240
begin
241241
session[:stream]&.close
242-
rescue
243-
nil
242+
rescue StandardError
243+
# Ignore close-related errors from already closed/broken streams.
244244
end
245245
@sessions.delete(session_id)
246246
end

0 commit comments

Comments
 (0)