Skip to content

[ruby] Default timeout to 60 seconds for the Typhoeus library - #25847

Merged
wing328 merged 2 commits into
OpenAPITools:masterfrom
vovanmozg:ruby-typhoeus-default-timeout
Nov 27, 2026
Merged

wing328 merged 2 commits into
OpenAPITools:masterfrom
vovanmozg:ruby-typhoeus-default-timeout

Conversation

@vovanmozg

@vovanmozg vovanmozg commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

The Ruby client template defaults timeout to 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

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

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 = 0 value meant libcurl never timed out. To keep the previous behavior, set config.timeout = 0.

Written for commit 9be44c3. Summary will update on new commits.

View guided diff

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>
Suggested change
# Default to 60.
# Default to 60 seconds. Set to 0 to disable the timeout.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@wing328

wing328 commented Nov 27, 2026

Copy link
Copy Markdown
Member

thanks for the PR. lgtm

@wing328
wing328 merged commit 72c43dc into OpenAPITools:master Nov 27, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants