Merge pull request #286 from koic/use_rescue_standard_error_for_stream_close

Use `rescue StandardError` for stream close
This commit is contained in:
Koichi ITO 2026-04-04 01:32:27 +09:00 • committed by GitHub
commit 52371a31be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -150,8 +150,8 @@ module MCP
# removed from `@sessions` above, so other threads will not find them # removed from `@sessions` above, so other threads will not find them
# and will not attempt to close the same stream. # and will not attempt to close the same stream.
stream.close stream.close
rescue rescue StandardError
nil # Ignore close-related errors from already closed/broken streams.
end end
end end
@ -239,8 +239,8 @@ module MCP
begin begin
session[:stream]&.close session[:stream]&.close
rescue rescue StandardError
nil # Ignore close-related errors from already closed/broken streams.
end end
@sessions.delete(session_id) @sessions.delete(session_id)
end end