Skip to content

Conversation

@titusfortner
Copy link
Member

@titusfortner titusfortner commented Jan 5, 2026

User description

Whenever a ruby job gets into trouble, it hangs the build for hours unnecessarily.

💥 What does this PR do?

  • reduces read timeouts to 20 30 seconds for tests

🔧 Implementation Notes

  • 20 30 seconds should be plenty for everything we're doing.

💡 Additional Considerations

  • Doesn't actually prevent errors, just keeps things from getting out of hand when they happen.

Some remote tests and some large file transfer tests wanted 30 seconds. Could tweak further, this is easiest. Will adjust more if problems.


PR Type

Enhancement


Description

  • Reduces read timeout to 20 seconds for test drivers

  • Adds configurable http_client parameter to create_driver!

  • Simplifies driver instantiation logic with ternary operator


Diagram Walkthrough

flowchart LR
  A["create_driver! method"] -->|"adds http_client param"| B["Remote::Http::Default"]
  B -->|"sets read_timeout"| C["20 seconds"]
  A -->|"refactors logic"| D["Ternary operator"]
  D -->|"prevents hangs"| E["Faster test failures"]
Loading

File Walkthrough

Relevant files
Enhancement
test_environment.rb
Add configurable http_client with 20s timeout                       

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

  • Added http_client parameter to create_driver! method with default
    20-second read timeout
  • Refactored driver instantiation from if-else block to ternary operator
  • Consolidated driver creation options into single opts hash for cleaner
    code
  • Prevents indefinite hangs by enforcing shorter timeout on test HTTP
    clients
+4/-6     

@titusfortner titusfortner requested review from aguspe and p0deje January 5, 2026 07:16
@selenium-ci selenium-ci added the C-rb Ruby Bindings label Jan 5, 2026
@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Jan 5, 2026

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Jan 5, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Only pass http_client to remote driver

Refactor the driver instantiation to ensure the http_client option is only
passed when creating a remote driver via WebDriver::Driver.for.

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb [176-177]

-opts = {options: build_options(**), listener: listener, http_client: http_client}
-instance = private_methods.include?(method) ? send(method, **opts) : WebDriver::Driver.for(driver, **opts)
+base_opts = {options: build_options(**), listener: listener}
+instance = private_methods.include?(method) \
+  ? send(method, **base_opts) \
+  : WebDriver::Driver.for(driver, **base_opts.merge(http_client: http_client))
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that http_client is only for remote drivers and proposes a clean refactor to pass it conditionally, improving code clarity and robustness.

Low
Learned
best practice
Ensure http client is closed

If http_client is created internally, it should be closed in an ensure block
(especially in the block-yield path) so test failures don’t leak
sockets/handles.

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb [171-187]

 def create_driver!(listener: nil, http_client: nil, **, &block)
   check_for_previous_error
-  http_client ||= Remote::Http::Default.new(read_timeout: 20)
+
+  created_http_client = false
+  if http_client.nil?
+    http_client = Remote::Http::Default.new(read_timeout: 20)
+    created_http_client = true
+  end
 
   method = :"#{driver}_driver"
   opts = {options: build_options(**), listener: listener, http_client: http_client}
   instance = private_methods.include?(method) ? send(method, **opts) : WebDriver::Driver.for(driver, **opts)
   @create_driver_error_count -= 1 unless @create_driver_error_count.zero?
+
   if block
     begin
       yield(instance)
     ensure
-      instance.quit
+      begin
+        instance.quit
+      ensure
+        http_client.close if created_http_client && http_client.respond_to?(:close)
+      end
     end
   else
     @driver_instance = instance
   end
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - In tests creating external resources, ensure cleanup in ensure blocks so failures don’t leak resources.

Low
Possible issue
Name and forward keyword args explicitly

Rename the anonymous keyword argument splat to kwargs for improved clarity
and explicit forwarding.

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb [171-176]

-def create_driver!(listener: nil, http_client: nil, **, &block)
+def create_driver!(listener: nil, http_client: nil, **kwargs, &block)
   http_client ||= Remote::Http::Default.new(read_timeout: 20)
-  opts = {options: build_options(**), listener: listener, http_client: http_client}
+  opts = {options: build_options(**kwargs), listener: listener, http_client: http_client}
  • Apply / Chat
Suggestion importance[1-10]: 2

__

Why: Using an explicit name like **kwargs instead of the anonymous ** can slightly improve readability, but it is a stylistic preference as both are functionally equivalent in this context.

Low
  • Update

@titusfortner titusfortner merged commit d58b3a4 into trunk Jan 7, 2026
33 checks passed
@titusfortner titusfortner deleted the rb_test_client branch January 7, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants