appfolio / ae_page_objects

Page Objects for Capybara
MIT License
28 stars 9 forks source link

Retry Document#visit on Net::ReadTimeout #206

Closed tlconnor closed 6 years ago

tlconnor commented 6 years ago

Sometimes tests will flake due to a Net::ReadTimeout error. These have been identified as occurring when multiple page loads occur in quick succession.

Take the example below:

page.perform_some_action!
assert_equal "some validation error", page.validation_errors
SomeOtherPageObject.visit

In this example the perform_some_action! call results in a page load. If the following .visit call occurs before the page is fully loaded (including all ajax requests) the Net::ReadTimeout can occur. This issue is very easy to reproduce when using websocket libraries that initialize a websocket on page load. These libraries often fall back to long-polling, which can result in an HTTP request being held open for ~60s.

The issue is not completely solvable in ae_page_objects, however it can be mostly mitigated by adding retry logic to Page.load.