Repository navigation
[ruby] Default timeout to 60 seconds for the Typhoeus library - #25847
Conversation
The Faraday and HTTPX templates already default the timeout to 60 seconds. The Typhoeus template defaulted it to 0, which libcurl reads as no limit, so a call to a server that does not respond never returns.
There was a problem hiding this comment.
2 issues found across 11 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache:97">
P3: The comment dropped the meaning of 0. Say that 0 disables the timeout, for example `# Default to 60 seconds. Set to 0 to disable the timeout.`</violation>
</file>
<file name="samples/openapi3/client/features/dynamic-servers/ruby/lib/dynamic_servers/configuration.rb">
<violation number="1" location="samples/openapi3/client/features/dynamic-servers/ruby/lib/dynamic_servers/configuration.rb:174">
P2: The default is now 60, but the `defaults to 0` spec in this sample still asserts 0 for `Configuration.default.timeout`, `config.timeout`, and `request.options[:timeout]`, so it will fail. Update that spec to expect 60, and make the same change in the other four Ruby sample specs with this assertion.</violation>
</file>
Reply to a comment to ask cubic a question or push back. It learns from your replies.
View guided diff | Re-trigger cubic
| @cert_file = nil | ||
| @key_file = nil | ||
| @timeout = 0 | ||
| @timeout = 60 |
There was a problem hiding this comment.
P2: The default is now 60, but the defaults to 0 spec in this sample still asserts 0 for Configuration.default.timeout, config.timeout, and request.options[:timeout], so it will fail. Update that spec to expect 60, and make the same change in the other four Ruby sample specs with this assertion.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/openapi3/client/features/dynamic-servers/ruby/lib/dynamic_servers/configuration.rb, line 174:
<comment>The default is now 60, but the `defaults to 0` spec in this sample still asserts 0 for `Configuration.default.timeout`, `config.timeout`, and `request.options[:timeout]`, so it will fail. Update that spec to expect 60, and make the same change in the other four Ruby sample specs with this assertion.</comment>
<file context>
@@ -171,7 +171,7 @@ def initialize
@cert_file = nil
@key_file = nil
- @timeout = 0
+ @timeout = 60
@params_encoding = nil
@debugging = false
</file context>
There was a problem hiding this comment.
Fixed: the five sample specs now expect 60.
|
|
||
| # The time limit for HTTP request in seconds. | ||
| # Default to 0 (never times out). | ||
| # Default to 60. |
There was a problem hiding this comment.
P3: The comment dropped the meaning of 0. Say that 0 disables the timeout, for example # Default to 60 seconds. Set to 0 to disable the timeout.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache, line 97:
<comment>The comment dropped the meaning of 0. Say that 0 disables the timeout, for example `# Default to 60 seconds. Set to 0 to disable the timeout.`</comment>
<file context>
@@ -94,7 +94,7 @@ module {{moduleName}}
# The time limit for HTTP request in seconds.
- # Default to 0 (never times out).
+ # Default to 60.
attr_accessor :timeout
</file context>
| # Default to 60. | |
| # Default to 60 seconds. Set to 0 to disable the timeout. |
There was a problem hiding this comment.
The comment is shared by all three libraries, and with Faraday (net_http) config.timeout = 0 makes a request fail at once with ApiError: Connection timed out. So "Set to 0 to disable the timeout" would be wrong there.
|
thanks for the PR. lgtm |
The Ruby client template defaults
timeoutto 60 seconds for Faraday (#10405) and HTTPX, but to 0 for Typhoeus, which libcurl reads as no limit.This PR sets the Typhoeus default to 60 seconds and fixes the comment "Default to 0 (never times out)". To keep the old behavior, set
config.timeout = 0.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
cc @cliffano @zlx @autopp
Summary by cubic
Sets the Typhoeus Ruby client default request timeout to 60 seconds so requests to a non-responsive server no longer hang indefinitely, matching the Faraday and HTTPX defaults. The old
timeout = 0value meant libcurl never timed out. To keep the previous behavior, setconfig.timeout = 0.Written for commit 9be44c3. Summary will update on new commits.