Skip to content

Commit

Permalink
Fix capybara session errors
Browse files Browse the repository at this point in the history
When running feature specs sometimes chromium crashes. One of the
several errors that pop up is this one:

  1.3) Failure/Error: Unable to infer file and line number from
backtrace

    Selenium::WebDriver::Error::InvalidSessionIdError:
      invalid session id

Disabling the use of shared memory seems to fix this error because
Chrome does not use /dev/shm which can be tight on memory on CI
Pipelines or containers, and uses files in /tmp which can be a bit more
forgiving in tight environments at the expense of some performance.
  • Loading branch information
danidoni committed Oct 2, 2024
1 parent 67c85e9 commit 9de85b6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/api/spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Capybara::Selenium::Driver.load_selenium
browser_options = Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--disable-gpu'
browser_options.args << '--disable-dev-shm-usage'
browser_options.args << '--headless'
browser_options.args << '--no-sandbox' # to run in docker
browser_options.args << '--window-size=1280,1024'
Expand All @@ -24,6 +25,7 @@
Capybara::Selenium::Driver.load_selenium
browser_options = Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--disable-gpu'
browser_options.args << '--disable-dev-shm-usage'
browser_options.args << '--headless'
browser_options.args << '--no-sandbox' # to run in docker
browser_options.add_emulation(device_metrics: { width: 320, height: 568, pixelRatio: 1, touch: true })
Expand Down

0 comments on commit 9de85b6

Please sign in to comment.