fix(agent-core): drop the bracketed [::1] from child-process NO_PROXY - #2481
fix(agent-core): drop the bracketed [::1] from child-process NO_PROXY#2481xy200303 wants to merge 2 commits into
Conversation
new URL(...).pathname yields /C:/... on Windows, which produced bogus C:\C:\... fixture paths and made every mcpCore test spawning a fixture fail with 'Cannot find module'. Match the v1 tests and convert via fileURLToPath so the suites run on Windows.
When an HTTP(S) proxy is configured, proxyEnvForChild/reconcileChildNoProxy injected NO_PROXY=localhost,127.0.0.1,::1,[::1] into every spawned stdio MCP server. Python's httpx (the HTTP client behind fastmcp and many other MCP servers) crashes while parsing the bracketed [::1] entry (InvalidURL: Invalid port: ':1]'), so every Python-based MCP server failed at startup with 'Connection closed' for all proxy users. The bracketed form only exists for undici 7.x's own NO_PROXY parser, which mis-parses a bare ::1 as host ':' port '1'. That concern applies to our in-process dispatcher, not to child env: children get the unbracketed loopback list (localhost,127.0.0.1,::1), which both httpx and undici handle. Losing the proxy bypass for literal http://[::1] URLs in Node children is a far smaller risk than breaking every Python child outright. resolveNoProxy keeps its previous default (bracketed list) for the in-process dispatcher; only the child-env builders pass the reduced list. Refs MoonshotAI#1931
🦋 Changeset detectedLatest commit: 8de4b45 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8de4b45511
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| const LOOPBACK_NO_PROXY = ['localhost', '127.0.0.1', '::1', '[::1]'] as const; | ||
|
|
||
| // Spawned child processes get the loopback list WITHOUT the bracketed |
There was a problem hiding this comment.
Move v2 explanatory comment into the module header
In packages/agent-core-v2, the scoped comment convention allows explanatory comments only in the top-of-file /** */ block and explicitly forbids comments beside statements; this new inline block above CHILD_LOOPBACK_NO_PROXY violates that convention, so please move the child-process rationale into the module header or otherwise avoid a statement-adjacent comment.
AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L15-L19
Useful? React with 👍 / 👎.
Related Issue
Resolve #1931
Problem
See linked issue. In short: with an HTTP(S) proxy configured, every spawned stdio MCP server inherits
NO_PROXY=localhost,127.0.0.1,::1,[::1]. Python's httpx (used by fastmcp and many other MCP servers) crashes while parsing the bracketed[::1]entry (httpx.InvalidURL: Invalid port: ':1]'), so every Python-based MCP server fails at startup withConnection closedfor proxy users. Reproduced locally with httpx 0.28.1.What changed
[::1]entry only exists for undici 7.x's NO_PROXY parser (it mis-parses a bare::1as host:port1), which matters for the in-process dispatcher — not for child processes.proxyEnvForChild()andreconcileChildNoProxy()now pass a reduced loopback list (localhost,127.0.0.1,::1) that both httpx and undici handle.resolveNoProxy()keeps its previous default (bracketed list) for the in-process dispatcher and gains an optionalloopbackHostsparameter; existing callers are unaffected.http://[::1]URLs — a rare edge compared to every Python child crashing at startup.test/mcpCore/stubs.ts): resolve fixture paths withfileURLToPathso the mcpCore suites run on Windows (new URL(...).pathnameyields/C:/...there).Checklist
gen-changesetsskill, or this PR needs no changeset. (changeset added)gen-docsskill, or this PR needs no doc update. (no doc update needed)