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]: --extension mode: relay does not reconnect to browser extension after disconnect #41874
When the browser extension disconnects from the MCP relay (e.g. Chrome service worker idle timeout after 5 min of inactivity, browser restart, or extension reload), the relay never attempts to reconnect. Any subsequent MCP tool call fails with Extension not connected, and the only recovery is restarting the entire MCP server.
Steps to reproduce
Start the MCP server with extension mode: PLAYWRIGHT_MCP_EXTENSION_TOKEN=<token> npx @playwright/mcp --extension --browser chrome
Connect the extension and use it normally.
Wait ~5 minutes without any tool calls (Chrome MV3 service worker idle timeout), or close and reopen the browser, or reload the extension.
Call any MCP tool (e.g. browser_navigate).
Expected: the relay automatically re-opens connect.html and reconnects (token bypass makes this silent).
Actual: tool call fails with Extension not connected. The relay WebSocket server is still running but _extensionConnection is null and nothing re-triggers _connectBrowser.
Root cause
In packages/playwright-core/src/tools/mcp/cdpRelay.ts, when the extension connection closes, the handler clears CDP state and calls onExtensionDisconnect but never re-invokes _openConnectPageInBrowser to bring the extension back.
establishExtensionConnection is only called once from extensionContextFactory.ts at startup and is never called again, so there is no automatic recovery path.
Suggested fix
After extension connection close resets state, call _openConnectPageInBrowser again. Guard it so it does not fire during initial construction or intentional stop() shutdown.
Activity
fix(mcp): reconnect to the browser after disconnect