Skip to content

[Feature #21347] Add open_timeout as an overall timeout option for TCPSocket.new #13909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 17, 2025

Conversation

shioimm
Copy link
Contributor

@shioimm shioimm commented Jul 16, 2025

With this change, TCPSocket.new now accepts the open_timeout option.
This option raises an exception if the specified number of seconds has elapsed since the start of the method call, even if the operation is still in the middle of name resolution or connection attempts.

The addition of this option follows the same intent as the previously merged change to Socket.tcp .
Feature #21347
#13368

shioimm added 2 commits July 16, 2025 21:03
…`TCPSocket.new`

With this change, `TCPSocket.new` now accepts the `open_timeout` option.
This option raises an exception if the specified number of seconds has elapsed since the start of the method call,
even if the operation is still in the middle of name resolution or connection attempts.

The addition of this option follows the same intent as the previously merged change to `Socket.tcp`.
[Feature #21347](https://bugs.ruby-lang.org/issues/21347)
ruby#13368
@shioimm shioimm force-pushed the open_timeout-TCPSocket_new branch from 7126eb6 to 636696f Compare July 16, 2025 12:04
@shioimm shioimm changed the title Add open_timeout as an overall timeout option for TCPSocket.new [Feature #21347] Add open_timeout as an overall timeout option for TCPSocket.new Jul 16, 2025

This comment has been minimized.

# [:open_timeout] Specifies the timeout in seconds from the start of the method execution.<br>If this timeout is reached while there are still addresses that have not yet been attempted for connection, no further attempts will be made.
# [:Specifies the timeout in seconds from the start of the method execution.<br>If this timeout is reached while there are still addresses that have not yet been attempted for connection, no further attempts will be made.<br>If this option is specified together with other timeout options, an +ArgumentError+ will be raised.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The head of the line ([:open_timeout] Specifies) is destroyed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing it out!

@shioimm shioimm merged commit ba49005 into ruby:master Jul 17, 2025
92 of 94 checks passed
@shioimm shioimm deleted the open_timeout-TCPSocket_new branch July 17, 2025 09:15
@osyoyu
Copy link
Contributor

osyoyu commented Jul 17, 2025

Super cool, thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants