Skip to content

Commit 52371a3

Browse files
authored
Merge pull request #286 from koic/use_rescue_standard_error_for_stream_close
Use `rescue StandardError` for stream close
2 parents 6bada5f + d3f400f commit 52371a3

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)