Repository navigation
fix(cli): the npm commands the CLI runs for itself use npm's own noproxy setting - #12242
josephfarina wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Requesting changes: the fix looks right, but one statement in the pull request description does not match the code.
Blocking
- The description says
runNpmis "the one place the CLI starts npm", but the CLI also starts npm inrunNpmPackJson(packages/cli/foundation/integrations/pack-state.mjs), ininstallJscodeshift(packages/cli/assets/codemods/ensure-jscodeshift.mjs) and in this change's ownreadNpmNoProxy, so please reword it to say thatrunNpmis the one runner for the npm commands the CLI runs for itself (its cache installs and registry queries).
The code matches how npm behaves: npm checks its noproxy setting once per agent and then lets the environment's no_proxy decide each connection, so copying the setting into NO_PROXY and no_proxy is what makes it apply, and the new tests pass. One non-blocking suggestion is inline: the guard test passes env itself, so runNpm's own wiring is not covered.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim (changeset): the npm commands the CLI runs for itself now use npm's
noproxysetting. Verified:cache.mjs:431-443,:449,:472. - Claim (changeset): those commands install into the per-user cache and ask the registry for versions. Verified:
cache.mjs:506-526,:537-553,:1255-1274. - Claim (changeset): before, a shell
NO_PROXYnaming the registry sent npm straight to it despite npm's proxy settings. Verified in npm 11's@npmcli/agent(lib/index.js:11-36,lib/agents.js:39-46,lib/proxy.js:73-74). - Claim (changeset): the first command that needed the cache waited until npm gave up, then failed. Verified in substance: npm's agent sets no connection timeout, and the install then fails (
cache.mjs:1276-1288). - Claim: npm documents the variable as the setting's default but lets the variable win. Verified (npm's
noproxydefinition and agent source above). - Claim: the range query and the daily check are affected the same way. Verified: both call
runNpm. - Claim: nothing changes where npm has no
noproxysetting. Verified:cache.mjs:389-392,:407. - Claim: the wait ends at npm's 5-minute limit. Inexact: the install passes a 30-second fetch timeout and has a 15-minute bound (
cache.mjs:587-593,:686); the multi-minute wait comes from the system's connect timeout. - Claim: the global-mode record's carried-Core install and update-check requirements govern. Verified.
- Claim: the setting is read once per run, and both variables are set only when npm has one. Verified:
cache.mjs:406-413,:440-442. - Claim:
runNpmis the one place the CLI starts npm. False:pack-state.mjs:250-262,ensure-jscodeshift.mjs:47-62,cache.mjs:376-388. - Claim: measurements on the author's machine (hang, 24-second answer,
npm viewresults). Consistent with npm's source; not reproduced. - Claim: regression tests for the setting, the environment and the guard. Verified:
cache.test.mjs:1031-1081, passing. - Claim: no new public API and no internal context. Verified: the module is outside the package's
exportsmap. - Claim: tests, strict typecheck, ESLint and Prettier on the changed files. Verified for the changed files.
- File
.changeset/npm-honors-its-noproxy.md: clear. - File
packages/cli/foundation/release/cache.mjs: clear. - File
packages/cli/foundation/release/cache.test.mjs: clear; one non-blocking suggestion.
There was a problem hiding this comment.
Approved pending CI: the CI workflow stopped at admission on this head ("CI is full"), so it needs a re-run before merge; Lint and the CLI smoke test passed.
The earlier blocking point is resolved: the description now calls runNpm the one runner for the npm commands the CLI runs for itself, and the guard test now fails if runNpm stops building the environment. One optional test suggestion is inline, and one optional description fix:
- The list of the CLI's other npm runs leaves out the
npm packthatintegration verifyruns (packages/cli/api/integration/pack-check.mjs,runNpmPack); it also reads no registry, so only the list is incomplete.
Claims and files checked
Review mode: incremental; reason: none
- Claim (changeset): the npm commands the CLI runs for itself now use npm's
noproxysetting. Verified:cache.mjs:434-442,:448,:471. - Claim (changeset): those commands install into the per-user cache and ask the registry for versions. Verified:
cache.mjs:509,:537,:1092. - Claim (changeset): before, a shell
NO_PROXYnaming the registry sent npm straight to it despite npm's proxy settings. Verified in npm's@npmcli/agent(lib/index.js:11-19,lib/agents.js:20-45,lib/proxy.js:73-74). - Claim (changeset): the first command that needed the cache waited, then failed. Verified in substance: the wait ends at the system's connect timeout, then the install fails.
- Claim: outside a project the global CLI printed the install line and then nothing for minutes, because npm sets no connection timeout of its own. Verified in npm's agent (
lib/options.js:27-28); the transcript is the author's. - Claim: npm documents
NO_PROXYas the default of itsnoproxysetting, but npm 11 lets the variable win. Verified: npm'snoproxydefinition and the agent source above. - Claim: the range query and the daily update check are affected the same way. Verified: both default to
runNpm(cache.mjs:509,:537). - Claim: nothing changes where npm has no
noproxysetting. Verified:cache.mjs:389-392,:407. - Claim: before this change
runNpmstarted npm with the run's environment as is. Verified: the base passes no environment of its own. - Claim:
runNpmis the one runner for the CLI's own cache installs and registry queries. Verified:cache.mjs:509,:537,:1092; no other CLI code runsnpm installornpm view. - Claim: the global-mode record's carried-Core install and update-check requirements govern. Verified.
- Claim: the setting is read once per run, both variables are set only when npm has one, and
runNpmruns npm with them. Verified:cache.mjs:376-393,:406-413,:439-442. - Claim: the CLI's other npm runs stay as they are, since the dry-run pack reads no registry and the jscodeshift install uses the project's package manager. Verified (
pack-state.mjs:281-287,ensure-jscodeshift.mjs:51-63); the list leaves outintegration verify'snpm pack(pack-check.mjs:291-301), which also reads no registry. - Claim: measurements on the author's machine (150-second hang, 24-second answer,
npm viewresults). Consistent with npm's source; not reproduced. - Claim: regression tests for the setting, the environment and
runNpm's guard path, the last failing whenrunNpmdoes not build the environment. Verified:cache.test.mjs:1031-1090pass, and the guard test fails whencache.mjs:442passesprocess.envinstead. - Claim: one defect, no tag-along, no hidden public API or default, no internal context. Verified: the module is outside the package's
exportsmap. - Claim: the cache, notices and choose suites, strict typecheck, ESLint and Prettier pass on the changed files. Verified for the new tests, the notices and choose suites, typecheck, ESLint and Prettier; three existing process-table tests in the cache suite were not reproducible and fail the same way without this change.
- File
.changeset/npm-honors-its-noproxy.md: clear. - File
packages/cli/foundation/release/cache.mjs: clear; one optional inline suggestion. - File
packages/cli/foundation/release/cache.test.mjs: clear.
| : options.npm | ||
| ? null | ||
| : configuredNoProxy === undefined | ||
| ? (configuredNoProxy = readNpmNoProxy(npm)) |
There was a problem hiding this comment.
Non-blocking suggestion: no test reaches this read. Replacing readNpmNoProxy(npm) here with null leaves every test green, because the guard test passes noProxy and the other runNpm tests pass npm. A test of runNpm with neither option, through a seam for the npm that readNpmNoProxy starts, would cover it.
…pm's own noproxy setting
…pm's noproxy setting runNpm reads npm's own noproxy setting once per run with `npm config get noproxy`, a sixth child process in cache.mjs. The runner list named five.
There was a problem hiding this comment.
Approved pending CI: the test-node shards and docsite-browser had not finished on this head, so merging waits until they pass.
The new commit lists cache.mjs's sixth spawnSync in the CLI's runner inventory; that test failed on the previous head, which the last review missed, and it passes now. No blocking issue remains. Optional:
- The inventory's new text puts the
noproxyread under "npm (under npm-guard.mjs)", butreadNpmNoProxystarts npm directly (inline suggestion). - The earlier inline suggestion still applies: no test reaches
runNpm's default read of npm's setting (cache.mjs:440). - The description's list of the CLI's other npm runs leaves out the
npm packthatintegration verifyruns (pack-check.mjs,runNpmPack); it also reads no registry, so only the list is incomplete.
Claims and files checked
Review mode: incremental; reason: none
- Claim (changeset): the npm commands the CLI runs for itself now use npm's
noproxysetting. Verified:cache.mjs:434-442,:448,:471. - Claim (changeset): those commands install into the per-user cache and ask the registry for versions. Verified:
cache.mjs:509,:537,:1092. - Claim (changeset): before, a shell
NO_PROXYnaming the registry sent npm straight to it despite npm's proxy settings. Verified in npm's agent source: the agent drops npm'snoproxywhen it decides each connection and falls back to the environment. - Claim (changeset): the first command that needed the cache waited, then failed. Verified in substance: npm's agent sets no connection timeout, so the wait ends at the system's connect timeout, then the install fails.
- Claim: outside a project the global CLI printed the install line and then nothing for minutes, because npm sets no connection timeout of its own. Verified in npm's agent options (
connection: 0); the transcript is the author's. - Claim: npm documents
NO_PROXYas the default of itsnoproxysetting, but npm 11 lets the variable win. Verified in the agent source above. - Claim: the range query and the daily update check are affected the same way. Verified: both default to
runNpm(cache.mjs:509,:537). - Claim: nothing changes where npm has no
noproxysetting. Verified:cache.mjs:389-392,:407. - Claim: before this change
runNpmstarted npm with the run's environment as is. Verified: the base passes no environment of its own. - Claim:
runNpmis the one runner for the CLI's own cache installs and registry queries. Verified:cache.mjs:509,:537,:1092; no other CLI code runsnpm installornpm viewfor the cache. - Claim: the global-mode record's carried-Core install and update-check requirements govern. Verified: both are current.
- Claim: the setting is read once per run, both variables are set only when npm has one, and
runNpmruns npm with them. Verified:cache.mjs:376-393,:406-413,:439-442. - Claim: the CLI's other npm runs stay as they are, since the dry-run pack reads no registry and the jscodeshift install uses the project's package manager. Verified (
pack-state.mjs:281-287,ensure-jscodeshift.mjs:51-63); the list leaves outintegration verify'snpm pack(pack-check.mjs:291-301), which also reads no registry. - Claim: measurements on the author's machine (150-second hang, 24-second answer,
npm viewresults). Consistent with npm's source; not reproduced. - Claim: regression tests for the setting, the environment and
runNpm's guard path, the last failing whenrunNpmdoes not build the environment. Verified:cache.test.mjs:1020-1091pass, and the guard test fails whencache.mjs:442passesprocess.envinstead. - Claim: one defect, no tag-along, no hidden public API or default, no internal context. Verified: the module is outside the package's
exportsmap, and no internal context was found. - Claim: the cache, notices and choose suites, strict typecheck, ESLint and Prettier pass on the changed files. Verified for the new tests and the notices (30) and choose (18) suites; typecheck and Lint pass in CI on this head; three existing process-table tests in the cache suite could not run here and fail the same way without this change.
- File
.changeset/npm-honors-its-noproxy.md: clear. - File
packages/cli/foundation/doc-compiler/doc-loads.test.mjs: clear; it now matches the sixspawnSyncsites incache.mjs; one optional inline wording suggestion. - File
packages/cli/foundation/release/cache.mjs: clear; the earlier optional inline suggestion on line 440 still applies. - File
packages/cli/foundation/release/cache.test.mjs: clear.
| 'foundation/release/cache.mjs': { | ||
| runs: 'npm (under npm-guard.mjs), to install and look up CLI releases in the per-user cache; each installed release once, to check it starts and reports its version; and ps (tasklist on Windows), to confirm the process a stale lock records is node or npm before ending it', | ||
| sites: ['child_process.spawnSync ×5'], | ||
| runs: "npm (under npm-guard.mjs), to install and look up CLI releases in the per-user cache, and once per run to read npm's own noproxy setting; each installed release once, to check it starts and reports its version; and ps (tasklist on Windows), to confirm the process a stale lock records is node or npm before ending it", |
There was a problem hiding this comment.
Non-blocking suggestion: this reads as if the noproxy read also runs under npm-guard.mjs, but readNpmNoProxy starts npm directly with its own 30-second limit (cache.mjs:377-388). Something like "…in the per-user cache, and, directly, once per run to read npm's own noproxy setting; …" would match what the module does.
- #12694 fix(cli): the Order Detail template's discount uses a minus sign held to its amount Author: @josephfarina - #12114 fix(templates): reset, reply, send and go-into icons mirror in right-to-left pages Author: @josephfarina - #12143 refactor(templates): example blocks lay out with HStack and VStack instead of flex wrappers Author: @josephfarina - #12158 fix(core): ChatComposer keeps its send action inside the composer on a narrow screen Author: @josephfarina - #12242 fix(cli): the npm commands the CLI runs for itself use npm's own noproxy setting Author: @josephfarina - #12283 fix(core): dark secondary text meets 4.5:1 on the neutral fill over the page and cards Author: @josephfarina - #12290 fix(Markdown): keep bulleted and numbered lists inside their column Author: @josephfarina - #12372 [fix] Heading: a missing level renders an h2 and warns, instead of crashing Author: @josephfarina - #12447 spec(AST-057): the swipe codemod's paths match it in any lifecycle folder Author: @josephfarina - #12475 fix(templates): on a phone the settings search moves under the title Author: @josephfarina - #12530 fix(cli): the contact-form template fits a phone; its section fills the width up to 800px Author: @josephfarina
|
Landed in #12812. |
User impact
On a machine whose shell sets
NO_PROXYto a list that names the npm registry's domain, while npm's own settings (proxy,https-proxyand a narrowernoproxy) send the registry through a proxy, the CLI installed for the computer hung outside a project:npm documents the
NO_PROXYvariable as the default of itsnoproxysetting, but npm 11 lets the variable win over the setting. So the npm the CLI starts went straight to a registry it could not reach. The same applies to the registry queries the CLI runs through npm (the newest release a project's range allows, and the daily update check).After this change, the npm commands the CLI runs for itself use npm's own
noproxysetting, and the same command answers:Nothing changes where npm has no
noproxysetting of its own: the shell's variable stands, as npm's default.Problem and solution fit
runNpm, the one runner for the npm commands the CLI runs for itself (its cache installs and registry queries), starts npm with the run's environment as is. npm 11 readsNO_PROXYfrom that environment ahead of its ownnoproxysetting, so the setting never takes effect while the variable names the registry.Expected behavior and authority
spec:AST-081FR3 and FR6: outside a project, a command that reads components uses the carried Core, which the CLI installs into its cache once; the install must complete where npm itself is configured to reach the registry.Smallest restoration
foundation/release/cache.mjs:readNpmNoProxy(npm)asks npm for its ownnoproxysetting (npm config get noproxy, once per run);npmEnvironment(env, noProxy)setsNO_PROXYandno_proxyto it, only when npm has one;runNpm, the one runner for the npm commands the CLI runs for itself (its cache installs and registry queries), runs npm in it. The CLI's other npm runs are left as they are:npm pack --dry-runforintegration checkreads no registry, and the codemods' jscodeshift install is a project install in the project's own package manager.Evidence
NO_PROXYnames the registry's domain; npm's settings: a proxy andnoproxy=localhost,127.0.0.1,::1), with a fresh cache, outside a project:astryx component Button --densefrom the current canary hung at the install line (stopped at 150 s); with only this file changed in that copy, it answered in 24 s.npm view @astryxdesign/cli versionin that shell: hangs as is and with--noproxy=localhost; answers in 1 s withNO_PROXYset to npm's own setting.null, or fails; the environment replaces aNO_PROXYthat names the registry and leaves it as is when npm sets nothing or the same list; the npmrunNpmstarts gets that environment through the guard it runs under (this test fails whenrunNpmdoes not build it).Scope
Components: CLI (the npm commands it runs for itself)
Testing
vitest run --project nodeoverfoundation/release/cache.test.mjs(41 passed, 3 new),foundation/release/notices.test.mjs(30 passed) andfoundation/release/choose.test.mjs(18 passed).tsc --project tsconfig.strict.json, ESLint and Prettier on the changed files.