Skip to content

fix(driver): don't launch a browser to reset or quit when none has started - #356

Open
andrewfader wants to merge 1 commit into
rubycdp:mainfrom
andrewfader:reset-quit-without-browser
Open

andrewfader wants to merge 1 commit into
rubycdp:mainfrom
andrewfader:reset-quit-without-browser

Conversation

@andrewfader

Copy link
Copy Markdown

Driver#reset! and Driver#quit both go through browser, which launches Chrome if no browser exists yet. When the launch for a test fails, for example with Ferrum::ProcessTimeoutError on an overloaded CI box, Capybara's reset! after the test launches Chrome again and waits another full process_timeout, only so it can reset a browser that never ran a page. quit does the same: on a driver that never started a browser, it starts one just to close it.

We hit this in CI: one slow launch turned into several timeouts in a row during teardown, which pushed the example past our job's deadline.

The fix is that reset! returns early when no browser has started, and quit closes the browser only if one exists. The next visit still launches a browser as before, so a launch that fails once is still retried on the next test.

Tests: two examples in spec/lib/driver_spec.rb that stub Browser.new to raise ProcessTimeoutError. Without the change both fail (expected no Exception, got #<Ferrum::ProcessTimeoutError ...>); with it both pass. RuboCop is clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant