Xvfb frequently fails to start with `-browsers` convenience image

We’ve been running our builds using the ruby image with the -browsers flag. In the past month or so, we’ve started seeing an increasingly large amount of flake. It complains that “Process unexpectedly closed with status 1”. Digging deeper into the selenium logs, I saw an error with geckodriver unable to connect to the display on :99. Deeper still, it appears that Xvfb is not properly loading in these cases. I’ve written a script to detect when the display is booted up by checking the /tmp/.X11-unix directory. But after waiting for 2 minutes, on the builds that fail, Xvfb has still not loaded.

7 Likes

Prefixing end to end test runs with xvfb-run -a seems to have resolved the issue for now. But it seems to me like this shouldn’t be necessary.

1 Like

This issue is also being seen running Cypress - see Missing X server or $DISPLAY · Issue #31484 · cypress-io/cypress · GitHub

This is a recent regression in CircleCI and is not being seen on GitHub Actions.

I’ve asked the support team for more information on the issue. They replied that forcing the X server to run in background is a best practice. I totally disagree, but I don’t have much choice and accept it.

We do it this way.

          command: |
            set +e
            Xvfb :99 -screen 0 1280x1024x24
            if [ $? -eq 0 ]; then
              echo "Xvfb started successfully"
            else
              echo "Xvfb is already running"
            fi
          background: true

The issue started 3 weeks ago on few of our builds. But as we are running cypress intensively … it was quite painful.

This is the exact answer i’ve received:

You’re right that repeatability is a core expectation from CI platforms.
While our convenience images do include Xvfb, we’ve found that explicitly starting services leads to more consistent and predictable behavior across builds. The 95/5% split you’re seeing suggests there could also be a timing or resource-related edge cases affecting your builds.
By explicitly stating it; it ensures the service is always running regardless of environment variables or container initialization quirks.

3 Likes