Skip to content

remoteEndpoint fails with Playwright run-server because browserName is not forwarded #408

@davzucky

Description

@davzucky

Summary

We want to use @playwright/cli from a development container while the browser runs in a separate Playwright service container. This is the same setup we already use successfully for E2E tests with @playwright/test and chromium.connect(...).

With @playwright/cli, configuring browser.remoteEndpoint against a Playwright run-server endpoint fails before opening a page.

Use Case

Our devcontainer has a Playwright service:

playwright:
  image: mcr.microsoft.com/playwright:v1.60.0-noble
  command: npx -y playwright@1.60.0 run-server --port 3456 --host 0.0.0.0

Our application containers can reach it at:

ws://playwright:3456/

This works with @playwright/test using chromium.connect(...). We would like playwright-cli to work the same way so agents/developers can run browser automation commands without installing or launching a browser in the development image.

Reproduction

Start a Playwright server:

docker run --rm --name playwright-server \
  -p 3456:3456 \
  mcr.microsoft.com/playwright:v1.60.0-noble \
  /bin/sh -c "npx -y playwright@1.60.0 run-server --port 3456 --host 0.0.0.0"

Use .playwright/cli.config.json:

{
  "browser": {
    "browserName": "chromium",
    "isolated": true,
    "remoteEndpoint": "ws://localhost:3456/",
    "launchOptions": {
      "channel": "chrome"
    }
  }
}

Run:

playwright-cli open https://example.com --config=.playwright/cli.config.json

Actual Behavior

The CLI fails with:

Cannot read properties of undefined (reading 'launch')

With debug output, the inner error is server-side:

TypeError: Cannot read properties of undefined (reading 'launch')
    at PlaywrightServer._initLaunchBrowserMode

Expected Behavior

playwright-cli should use browser.browserName from the config when connecting to a Playwright run-server endpoint, and should open the page successfully:

### Page
- Page URL: https://example.com/
- Page Title: Example Domain

Local Validation

We patched the bundled playwright-core locally to pass browserName when connecting to the remote endpoint. With that patch and matching client/server Playwright versions, the CLI successfully opened https://example.com and produced a snapshot.

This appears to be caused by the playwright-core implementation used by @playwright/cli, not by the thin playwright-cli wrapper itself. I will link the corresponding core issue here once filed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions