teamcapybara / capybara

Acceptance test framework for web applications
http://teamcapybara.github.io/capybara/
MIT License
9.98k stars 1.44k forks source link

Under JRuby Capybara is hanging with default server (Puma) at the end of test suite #2762

Open dolzenko opened 1 month ago

dolzenko commented 1 month ago

Simple repro Rails 7 app attached [1]. The idea is that after doing

bin/rails test:system

the process never finishes after printing

Finished in 1.972128s, 0.5071 runs/s, 0.5071 assertions/s.
1 runs, 1 assertions, 0 failures, 1 errors, 0 skips

I firmly believe this is happening because when JRuby tries to kill/join the Puma reactor thread at shutdown [2], but being stuck in epollWait Puma thread won't die. With simple patch [3] it works on JRuby 9.3 but gives NullPointerException on 9.4 so it's just for illustration of the idea that Puma server should be probably shutdown in some specific way.

I'm also undecided if that should be reported to JRuby/Puma or here so suggestions welcome.

[1] https://github.com/dolzenko/capybara-puma-hanging-repro [2] https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/internal/runtime/ThreadService.java#L158 [3] https://github.com/teamcapybara/capybara/compare/master...dolzenko:capybara:patch-2