fix: await VirtualDisplay.get() — Xvfb DISPLAY becomes "[object Promise]", breaking all tab launches#5589
Open
Francisgood wants to merge 1 commit into
Open
Conversation
… a Promise
VirtualDisplay.get() (camoufox-js) is declared `async` and returns a
Promise<string>. In launchBrowserInstance() it was called without await:
vdDisplay = localVirtualDisplay.get();
so vdDisplay held the Promise itself. It then flowed into the launch
options as `virtual_display: vdDisplay`, where Camoufox stringified it to
the literal "[object Promise]" and passed it to Firefox as the X DISPLAY.
Every launch failed with:
Error: cannot open display: [object Promise]
<process did exit: exitCode=1>
which surfaces to clients as a 500 on POST /tabs on any Linux/Docker
build with the Xvfb virtual display enabled (added in the Mesa GL + Xvfb
WebGL change). The log line also recorded "display":{} — a serialized
unresolved Promise — confirming the value was never awaited.
Adding `await` resolves the display string (e.g. ":0") before it is used.
launchBrowserInstance() is already async, so this is safe. After the fix
the browser launches and logs "display":":0" / "browser pre-warmed".
|
I confirm the bug and that fix is working. |
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
On Linux/Docker builds with the Xvfb virtual display enabled (introduced in the Mesa GL + Xvfb WebGL change), every browser launch fails and
POST /tabsreturns500:The server log also records the display as an empty object — a serialized, unresolved Promise:
{"msg":"xvfb virtual display started","display":{},"attempt":1}Root cause
VirtualDisplay.get()incamoufox-jsis declaredasyncand returns aPromise<string>:In
launchBrowserInstance()(server.js) it was called withoutawait:vdDisplaythen flows into the launch options asvirtual_display: vdDisplay. Camoufox stringifies it to the literal"[object Promise]"and hands it to Firefox as the XDISPLAY, so Firefox tries to open a display literally named[object Promise]and exits with code 1.Fix
Add the missing
await:launchBrowserInstance()is alreadyasync, so this is safe.Verification
Built the image from the patched source and started a container. The crash loop is gone — the display now resolves to a real value and the browser pre-warms:
{"msg":"xvfb virtual display started","display":":0","attempt":1} {"msg":"camoufox launched","attempt":1,"virtualDisplay":true} {"msg":"browser pre-warmed","ms":3989}A subsequent
POST /tabs/ page navigation succeeds.node --check server.jspasses.Impact
Without this, any fresh Docker build with the virtual display enabled cannot create a single tab. One-character change (
await), no behavior change beyond correctly resolving the display string.