Skip to content

fix(mcp): Consider WAYLAND_DISPLAY for headed operation on Linux.#41265

Open
smurfix wants to merge 2 commits into
microsoft:mainfrom
smurfix:main
Open

fix(mcp): Consider WAYLAND_DISPLAY for headed operation on Linux.#41265
smurfix wants to merge 2 commits into
microsoft:mainfrom
smurfix:main

Conversation

@smurfix

@smurfix smurfix commented Jun 12, 2026

Copy link
Copy Markdown

On Linux a minimal(istic) installation might not contain XWayland, as it's no longer required for modern browsers.
Hence the DISPLAY envvar is not set. Thus, fallback to WAYLAND_DISPLAY.

@smurfix smurfix changed the title Consider WAYLAND_DISPLAY for headed operation on Linux. fix(mcp): Consider WAYLAND_DISPLAY for headed operation on Linux. Jun 12, 2026
@smurfix

smurfix commented Jun 12, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

const browser = await validateBrowserConfig(result.browser);
if (browser.launchOptions.headless === undefined)
browser.launchOptions.headless = os.platform() === 'linux' && !process.env.DISPLAY;
browser.launchOptions.headless = os.platform() === 'linux' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what im reading it seems like $WAYLAND_DISPLAY is often a string, and some forums suggest setting it to something known to be nonexistent (e.g. WAYLAND_DISPLAY=no) so im not sure we can just falsy check it here

can you please give a bit more of an explanation as to your setup so we can better understand why this would solve the problem and is the best approach to do so?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why people set WAYLAND_DISPLAY to "no" as opposed to simply unsetting it. Anyway, the reason somebody does this is most likely because they want to use X11 instead, i.e. DISPLAY is set anyway, so this is not a problem.

The reason why I need this is because X11 is widely considered to be fairly insecure all around; none of the tools I'm using need it any more; and because I want the installation to be as minimal as possible (don't want to assemble a Docker image with a heap of unused X11 libraries and all that …).

Alternate solution: add an explicit "--headed" option …

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding --headed sounds like a right approach if you deliberately want to run headed browser.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7289 passed, 1122 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

3 flaky ⚠️ [installation tests] › playwright-component-testing.spec.ts:21 › pnpm: @playwright/experimental-ct-react should work `@package-installations-windows-latest`
⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/chromium/chromium.spec.ts:371 › should produce network events, routing, and annotations for Service Worker `@chromium-ubuntu-22.04-node20`

39546 passed, 743 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants