Skip to content

[BUG] --debug=cli fails when a test creates multiple BrowserContexts #42485

Description

@li-zhixin

Version

  • @playwright/test: 1.62.0
  • @playwright/cli: 0.1.18 (latest)
  • @playwright/cli dependencies: playwright/playwright-core 1.63.0-alpha-2026-08-05
  • Node.js: 22.15.0
  • OS: Linux

Reproduction

Minimal repository:

https://github.com/li-zhixin/playwright-cli-multi-context-repro

Commands:

pnpm install
pnpm exec playwright install chromium
pnpm exec playwright test
pnpm exec playwright test --debug=cli --reporter=line

The regular test run passes. The CLI debug run pauses at the start. After attaching with:

pnpm exec playwright-cli attach tw-xxxxxx
pnpm exec playwright-cli -s=tw-xxxxxx resume

the test fails when the worker-scoped fixture creates a second context:

Error: browser.bind: Server is already started.

  10 |   precreatedContext: [
  11 |     async ({ browser }, use) => {
> 12 |       const context = await browser.newContext();

Minimal test shape

A worker-scoped fixture creates an additional context:

const test = base.extend({
  precreatedContext: [
    async ({ browser }, use) => {
      const context = await browser.newContext();
      await use(context);
      await context.close();
    },
    { scope: "worker" },
  ],
});

The test also uses Playwright Test's built-in page fixture.

Expected behavior

--debug=cli should support tests that create more than one BrowserContext. The CLI should bind the browser once or otherwise support all contexts created by the test.

Actual behavior

The test integration invokes browser.bind() for CLI debugging when a context is created. A later browser.newContext() attempts to start another browser server and throws Server is already started, preventing fixture setup and test execution.

This affects worker-scoped reusable-context fixtures that create an additional context alongside Playwright Test's built-in context.

Activity

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

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