Skip to content

fix: forward environment variables to browser subprocess#370

Open
tounano wants to merge 1 commit intovercel-labs:mainfrom
tounano:fix/headed-display-env
Open

fix: forward environment variables to browser subprocess#370
tounano wants to merge 1 commit intovercel-labs:mainfrom
tounano:fix/headed-display-env

Conversation

@tounano
Copy link

@tounano tounano commented Feb 4, 2026

Summary

  • Forward environment variables to browser subprocess via Playwright's env option
  • Enables --headed mode on Linux with virtual displays (Xvnc, Xvfb)
  • Adds env: { ...process.env } to all 3 browser launch paths

Problem

When using --headed mode on Linux with a virtual display, the browser fails to launch because the DISPLAY environment variable is not forwarded to the Chromium subprocess. Without the env option, Playwright doesn't pass any environment variables to the browser process.

Error: Missing X server or $DISPLAY

Solution

Pass env: { ...process.env } to Playwright's launch options:

  • launcher.launch() for regular ephemeral browsers
  • launcher.launchPersistentContext() for extension mode
  • launcher.launchPersistentContext() for profile mode

Test plan

  • pnpm typecheck passes
  • pnpm format:check passes
  • pnpm test passes (203 tests)
  • Manual verification with VNC on Linux

Fixes #369
Related: #155, #150

🤖 Generated with Claude Code

When launching browsers with Playwright, environment variables like DISPLAY
were not being forwarded to the browser subprocess. This caused --headed
mode to fail on Linux with virtual displays (Xvnc, Xvfb).

The fix adds `env: { ...process.env }` to all browser launch calls:
- launcher.launch() for regular ephemeral browsers
- launcher.launchPersistentContext() for extension and profile modes

Fixes vercel-labs#369
Related: vercel-labs#155, vercel-labs#150

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Feb 4, 2026

@tounano is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

--headed fails on Linux: DISPLAY env var not passed to browser subprocess

1 participant