fix(mcp): bind extension relay to IPv4 loopback for WSL2#41209
Closed
DakshUbhadia wants to merge 1 commit into
Closed
fix(mcp): bind extension relay to IPv4 loopback for WSL2#41209DakshUbhadia wants to merge 1 commit into
DakshUbhadia wants to merge 1 commit into
Conversation
Node.js defaults to the IPv6 loopback ([::1]) on WSL2, which Windows Edge
cannot reach due to WSL2 networking limitations.
This patch ensures the relay is reachable across the OS boundary by:
- Passing { host: '127.0.0.1' } to startHttpServer in extensionContextFactory.ts
- Normalizing '::1' to '127.0.0.1' in cdpRelay.ts as a defense-in-depth guard
Fixes microsoft#41180
Author
|
@microsoft-github-policy-service agree |
Member
|
This is just a hack to force ipv4, I don't think we want force ipv4. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #41180
The Problem:
When launching a Windows browser (like Microsoft Edge) via
PLAYWRIGHT_MCP_EXECUTABLE_PATHfrom a WSL2 environment, the Playwright Extension relay fails to establish a connection and times out.By default, Node's
startHttpServerwithout a specified host binds to::(IPv6), resulting in a generated extension URL containingws://[::1]:<port>. WSL2 does not automatically forward Windows IPv6 localhost traffic into the Linux container, breaking the connection.The Fix:
httpServerwithhost: '127.0.0.1'inextensionContextFactory.ts.CDPRelayServerconstructor to map::1to127.0.0.1so the generatedmcpRelayUrlquery parameter strictly uses an IPv4 address, which WSL2 successfully forwards from Windows.Testing: