r/ruby • u/Soft-Charity-6194 • Apr 07 '26
[Help] System Test Flakiness (Cuprite/Ferrum) after Ruby 3.3.10 Upgrade
Has anyone successfully stabilized a high-parallelism system test suite (Capybara + Cuprite/Ferrum) after moving to Ruby 3.3.10?
We recently upgraded from Ruby 3.2.4 to Ruby 3.3.10, and our CI environment (CircleCI) has become a minefield of intermittent failures. We’re seeing a very specific, head-scratching behavior:
The Symptom:
Standard user actions like click_link or click_button fail silently, even though the element is clearly visible in failure screenshots. However, trigger("click") works.
Our Setup:
- Ruby: 3.3.10
- Gems: Ferrum 0.17.2, Cuprite 0.17
- CI: CircleCI (Large Resource Class, 24x Parallelism)
- OS: Linux Docker (cimg/ruby:3.3)
- Browser: Headless Chrome
What we’ve already tried:
- Disabling YJIT: No noticeable improvement.
- Adding jemalloc: This actually made things worse, leading to
Ferrum::ProcessTimeoutError(Browser failing to produce a websocket URL within 60s). - Increasing Timeouts: Pushed
process_timeoutanddefault_max_wait_timeup significantly with no luck. - Resource Throttling: Reduced parallelism to 2, but the failures persisted.
Our Theory:
We suspect a synchronization issue between Ruby 3.3’s new Fiber scheduler and the Chrome DevTools Protocol (CDP). It feels like Ruby is sending the click command faster than the browser can attach event listeners or finish its layout phase, leading to "missed" clicks at the physical coordinate level.
My Questions for the Community:
- Has anyone else noticed an increase in
MouseEventFailedspecifically after the 3.3.x jump? - How are you handling
jemallocon CI so that it stabilizes Ruby without breaking the Chrome sub-process? - Are there specific
browser_options(likeheadless: "old") that you've found necessary for 3.3 compatibility?
7
u/retro-rubies Apr 07 '26
Usually it helps to add assertion after navigation it has finished before doing another interaction. I don't remember much details, but not every method does the lookup with timeout/wait. Just made up example:
^ brittle, there is no guarantee page A is loaded and link to B (if present on page A only) is present
^ better - it waits for page A to load before moving to clicking other link
There were some changes few months ago on Chrome side - see https://github.com/teamcapybara/capybara/issues/2800 for more info.
3
u/Deep_Ad1959 Apr 07 '26 edited Apr 26 '26
the fact that trigger('click') works but click_link doesn't strongly suggests a timing issue with event listeners not being attached yet when the click fires. this is classic in headless chrome under high parallelism because the browser gets CPU-starved and JS execution falls behind rendering. before going deeper into ruby/ferrum internals i'd try reducing parallelism to 12 and see if the failure rate drops proportionally. if it does, the fix is either better wait strategies before clicks or giving CI nodes more CPU headroom.
fwiw there's a tool that does this - https://assrt.ai/t/headless-chrome-test-flakiness
2
u/Live_Appointment9578 Apr 07 '26
Mate, my recommendation is to break down the big problem and try to fix it in parts. The posted question is too complicated for anyone keen enough to dig in for free and solve for you. The question seems AI generated, ask AI to break down the issue
2
u/jhirn Apr 07 '26
I started using playwright a couple years ago. I’ll never go back.
1
u/ghassen_rjab Apr 10 '26
I experienced the same issue I think. After ruby and dependencies' updates.
I encapsulated my fill_in and click_on call inside a within('form') do. It helped a lot.
1
u/dunkelziffer42 May 10 '26
Try out https://github.com/makandra/capybara-lockstep . It usually reduces the pain a lot. It got cuprite support recently.
1
u/rO_Oute Jul 03 '26
You can ask for a help ferrum author, mail me.
0
u/f9ae8221b Apr 07 '26
I suppose you are setting
jemallocusingLD_PRELOAD? Chrome is famously incompatible withjemalloc, what you can do is remove theLD_PRELOADenv var from inside your ruby process (e.g.boot.rb, orspec_helper.rbor something like that:-4
u/TheAtlasMonkey Apr 07 '26
Your setup is legacy.
Upgrade to latest.