Repository navigation
fix(xvfb): wait for the display before starting the browser - #708
Merged
Merged
Conversation
Xvfb#start returned right after spawning Xvfb, so a headful browser could start before the display accepted connections, exit at once and surface as ProcessTimeoutError. Xvfb now reports readiness through -displayfd and start blocks on it up to :process_timeout, raising Ferrum::Error when Xvfb exits or isn't ready in time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
xvfb: true, headless: falsethe browser sometimes fails to launch withProcessTimeoutError, long before:process_timeoutruns out.Xvfb#startspawned Xvfb and returned immediately, so Chrome could start before the display accepted connections, fail to open it and exit. It showed up as a flakyspec/browser/xvfb_spec.rbon CI: https://github.com/rubycdp/ferrum/actions/runs/44533707075/job/135593471572Fix
Xvfb is started with
-displayfd, which makes it write the display number once it is ready to accept connections.Xvfb#startblocks on that for up to:process_timeout. If Xvfb exits or isn't ready in time, it is killed andFerrum::Erroris raised instead of launching a browser that can't find its display.Spec
A new example launches a headful browser against an Xvfb wrapper that sleeps for a second before starting. It fails without the change and passes with it.