Search code examples
rubyrspeccapybaraheadlessxvfb

Capybara-webkit, rspec integration specs, and xvfb: webkit_server: Fatal IO error: client killed


I'm trying to get a suite of integration specs running on a ubuntu server CI box using the headless gem, xvfb, and capybara-webkit for headless testing. Everything works beautifully on a local dev box, but things get interesting once moved over to the CI server.

In the spec helper there is a bit of code wrapping :js enabled integration specs within a headless block like so:

  config.around(:each, :js => true) do |example|
    Headless.ly &example 
  end

Like I said, this all works nicely on a local dev box. On CI, which is using the headless gem and xvfb as the same user for tests for a different project, attempting to run the integration specs results in the following error when the spec would need to instantiate a browser instance:

webkit_server: Fatal IO error: client killed

I've been trying to figure out what could be causing that error, but can't even find a trace of where that might have come from, or any other information to help debug the issue.

So far I've checked/tried the following:

  • CI user definitely has permissions to run xvfb
  • Running "Xvfb :99 -ac" as the CI user gives one warning about a not found font, no other issues

Does anyone have any ideas what might be causing this, or where I could look for more info? I'm pretty stumped on this.

Thanks!


Solution

  • I'm not sure if this is entirely the right solution, but it seems to work for me. Instead of doing:

    bundle exec spec
    

    Run the command with Xvfb like so, and remove the use of the headless gem:

    xvfb-run bundle exec spec
    

    Seems a bit wrong, but it works.