You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] --debug=cli fails when a test creates multiple BrowserContexts #42485
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.
The bind is done per context rather than per browser. runAfterCreateBrowserContext in packages/playwright/src/index.ts calls runDaemonForContext, which always calls context.browser().bind(...) (packages/playwright/src/mcp/test/browserBackend.ts:125). Since the worker-scoped browser is shared, the second context reaches BrowserServer.start() again and that throws unconditionally (packages/playwright-core/src/server/browser.ts:220).
Binding once per browser and skipping it for contexts created later on the same browser looks like enough to fix it, and it keeps browser.bind() itself strict for real double-bind calls.
I can put up a PR with that plus a regression test in tests/mcp/cli-test.spec.ts if this is open for contribution.
Activity
lazerg commentedon Sep 1, 2026
The bind is done per context rather than per browser.
runAfterCreateBrowserContextinpackages/playwright/src/index.tscallsrunDaemonForContext, which always callscontext.browser().bind(...)(packages/playwright/src/mcp/test/browserBackend.ts:125). Since the worker-scoped browser is shared, the second context reachesBrowserServer.start()again and that throws unconditionally (packages/playwright-core/src/server/browser.ts:220).Binding once per browser and skipping it for contexts created later on the same browser looks like enough to fix it, and it keeps
browser.bind()itself strict for real double-bind calls.I can put up a PR with that plus a regression test in
tests/mcp/cli-test.spec.tsif this is open for contribution.