From 48014fd9bdc3f1d6b84668d6df23477585bdb262 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Sep 2026 12:58:41 +0000 Subject: [PATCH] Keep a crashed browser from eating the CI job A job intermittently produces no output after a build until the runtime cap cancels it, leaving chromedriver, chrome, and two crashpad handlers as orphans: the renderer crashes and the driver waits on it forever. Run Chrome with `--disable-dev-shm-usage`, keeping it off the small `/dev/shm` of CI runners and containers, where exhausting it crashes the renderer. As a second line of defense, cap `:js` examples at five minutes, so a hung browser fails one example with a backtrace and lets the rest of the suite run, instead of silently consuming the job's runtime cap. Co-Authored-By: Claude Fable 5 --- spec/support/capybara.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 38f60402..8855eb76 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -1,8 +1,12 @@ +require "timeout" + require "selenium/webdriver" Capybara.register_driver :headless_chrome do |app| + # `--disable-dev-shm-usage` keeps Chrome off the small `/dev/shm` of CI + # runners and containers, where exhausting it crashes the renderer. options = Selenium::WebDriver::Chrome::Options.new( - args: %w[--no-sandbox --headless], + args: %w[--no-sandbox --headless --disable-dev-shm-usage], ) # Point Selenium at a specific Chrome binary, e.g. inside a container @@ -23,3 +27,11 @@ Capybara.server = :webrick Capybara.javascript_driver = :headless_chrome + +RSpec.configure do |config| + # A crashed browser can leave the driver waiting forever: fail the example + # with a backtrace instead of eating the job's runtime cap. + config.around(:each, :js) do |example| + Timeout.timeout(300) { example.run } + end +end