Skip to content

[Bug]: MCP test server hangs when multiple healer agents run in parallel #39235

@SeoJaeWan

Description

@SeoJaeWan

Version

1.59.0-next

Steps to reproduce

  1. Create a project with 3 failing test files (e.g. fail-a.spec.ts, fail-b.spec.ts, fail-c.spec.ts) each containing an intentionally wrong selector
  2. Configure .mcp.json with the playwright-test MCP server
  3. Use Claude Code to launch 3 playwright-test-healer agents in parallel, one for each failing test
  4. Observe that only 1 agent completes while the other 2 hang indefinitely

Expected behavior

All 3 healer agents should complete their work, either fixing the tests or reporting errors.

Actual behavior

When multiple healer agents run in parallel sharing a single playwright-test MCP
server process, only 1 agent completes while the remaining agents hang indefinitely
waiting for MCP responses that never arrive.

Root cause: claimStdio() in testContext.ts monkey-patches process.stdout.write
during test execution (global setup/teardown). Since StdioServerTransport shares the
same process.stdout object reference, MCP JSON-RPC responses written during a
claimStdio window are silently swallowed by StringWriteStream instead of being sent
to the client.

Additionally, TestContext has a single _testRunnerAndScreen slot, so concurrent tool
calls create race conditions when multiple agents try to create/cleanup test runners
simultaneously.

Additional context

The issue can also be reproduced programmatically by sending 3 concurrent test_run
calls to the MCP server via stdin. Only the last response is received; the first two are
lost.

Video attached showing the reproduction.

fail-c.spec.ts.-.playwright.-.Visual.Studio.Code.2026-02-12.14-33-56.1.mp4

Environment

Environment:
System:
    OS: Windows 11 10.0.26100
    CPU: (28) x64 Intel(R) Core(TM) i7-14700
    Memory: 14.69 GB / 31.77 GB
Binaries:
    Node: 22.12.0
    npm: 10.9.0
IDEs:
    VSCode: 1.109.0
    Claude Code: 2.1.39
npmPackages:
    @playwright/test: 1.59.0-next

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions