Skip to content
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

[🐛 Bug]: Trying to terminate a ChildProcess that's already gone #14689

Open
johlym opened this issue Oct 30, 2024 · 1 comment
Open

[🐛 Bug]: Trying to terminate a ChildProcess that's already gone #14689

johlym opened this issue Oct 30, 2024 · 1 comment

Comments

@johlym
Copy link

johlym commented Oct 30, 2024

What happened?

Using selenium-webdriver 4.25.0 or 4.26.0, Ruby 3.2.2 (or 3.3.5), and teaspon 1.4.0, we run into an issue where Webdriver tries to terminate its child process and throws an exception because the process doesn't exist. (see log output)

This is slightly different than, but seemingly related to #14032, in that ErrNo::ERSCH is thrown, rather than Errno::ECHILD in #14032.

We are able to work around this by creating a small money patch to override the terminate method (as an initializer since this is a Rails app):

# config/initializers/selenium_monkey_patch.rb

require 'selenium-webdriver' # Ensure selenium-webdriver is loaded

module Selenium
  module WebDriver
    class ChildProcess
      # Monkey patch the terminate method to rescue from the browser
      # process already having been terminated for hashtag reasons.
      # Is similar but not exactly the same as the problem described
      # in https://github.com/SeleniumHQ/selenium/issues/14032
      def terminate(pid)
        Process.kill('SIGTERM', pid)
      rescue Errno::ECHILD, Errno::ESRCH
        # Process is already dead, no action needed
        p "MONKEYPATCH: Process is already dead, no action needed"
        p "MONKEYPATCH: Don't leave me this way!"
      end
    end
  end
end

How can we reproduce the issue?

Run `bundle exec teaspoon` under Ruby 3.2.2 or Ruby 3.3.5, with `selenium-webdriver` 4.25.0 or 4.26.0

Relevant log output

Teaspoon running default suite at http://127.0.0.1:43075/teaspoon/default
.........................

Finished in 0.03000 seconds
25 examples, 0 failures
bundler: failed to load command: teaspoon (/home/runner/work/elements/elements/vendor/bundle/ruby/3.2.0/bin/teaspoon)
/home/runner/work/elements/elements/vendor/bundle/ruby/3.2.0/gems/selenium-webdriver-4.25.0/lib/selenium/webdriver/common/child_process.rb:114:in `kill': No such process (Errno::ESRCH)
	from /home/runner/work/elements/elements/vendor/bundle/ruby/3.2.0/gems/selenium-webdriver-4.25.0/lib/selenium/webdriver/common/child_process.rb:114:in `terminate'
	from /home/runner/work/elements/elements/vendor/bundle/ruby/3.2.0/gems/selenium-webdriver-4.25.0/lib/selenium/webdriver/common/child_process.rb:68:in `stop'
	from /home/runner/work/elements/elements/vendor/bundle/ruby/3.2.0/gems/selenium-webdriver-4.25.0/lib/selenium/webdriver/common/service_manager.rb:110:in `stop_process'
	from /home/runner/work/elements/elements/vendor/bundle/ruby/3.2.0/gems/selenium-webdriver-4.25.0/lib/selenium/webdriver/common/service_manager.rb:71:in `stop'
	from /home/runner/work/elements/elements/vendor/bundle/ruby/3.2.0/gems/selenium-webdriver-4.25.0/lib/selenium/webdriver/common/service_manager.rb:53:in `block in start'
	from /home/runner/work/elements/elements/vendor/bundle/ruby/3.2.0/gems/selenium-webdriver-4.25.0/lib/selenium/webdriver/common/platform.rb:152:in `block in exit_hook'


### Operating System

macOS, Linux

### Selenium version

4.25.0

### What are the browser(s) and version(s) where you see this issue?

Headless chrome, firefox

### What are the browser driver(s) and version(s) where you see this issue?

latest as invoked by selenium-manager

### Are you using Selenium Grid?

n/a
Copy link

@johlym, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol diemol added C-rb and removed needs-triaging labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants