Skip to content

fix(cli): the npm commands the CLI runs for itself use npm's own noproxy setting - #12242

Closed
josephfarina wants to merge 3 commits into
mainfrom
josephfarina/npm-honors-its-noproxy
Closed

josephfarina wants to merge 3 commits into
mainfrom
josephfarina/npm-honors-its-noproxy

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

User impact

On a machine whose shell sets NO_PROXY to a list that names the npm registry's domain, while npm's own settings (proxy, https-proxy and a narrower noproxy) send the registry through a proxy, the CLI installed for the computer hung outside a project:

$ astryx component Button --dense
astryx: answered by CLI 0.7.17-… with Core 0.7.17-…, outside a project
astryx: installing CLI release 0.7.17-… into the per-user cache (once)...
(no output for minutes: npm sets no connection timeout of its own, so it waits on the system's)

npm documents the NO_PROXY variable as the default of its noproxy setting, 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 noproxy setting, and the same command answers:

astryx: installing CLI release 0.7.17-… into the per-user cache (once)...
package: @astryxdesign/core
# Button …

Nothing changes where npm has no noproxy setting of its own: the shell's variable stands, as npm's default.

Problem and solution fit

  1. Why does it happen? 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 reads NO_PROXY from that environment ahead of its own noproxy setting, so the setting never takes effect while the variable names the registry.
  2. Why does it harm the task? The first command outside a project that reads components needs that install, so the global install cannot answer at all on such a machine, and the wait gives no hint.
  3. Why does that matter? A global install must work in any folder on the machines people use, and these are the CLI's own installs.

Expected behavior and authority

  • spec:AST-081 FR3 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 own noproxy setting (npm config get noproxy, once per run); npmEnvironment(env, noProxy) sets NO_PROXY and no_proxy to 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-run for integration check reads no registry, and the codemods' jscodeshift install is a project install in the project's own package manager.

Evidence

  • On such a machine (stock shell: NO_PROXY names the registry's domain; npm's settings: a proxy and noproxy=localhost,127.0.0.1,::1), with a fresh cache, outside a project: astryx component Button --dense from 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 version in that shell: hangs as is and with --noproxy=localhost; answers in 1 s with NO_PROXY set to npm's own setting.
  • Regression tests: the setting is read from npm and is none when npm sets none, prints null, or fails; the environment replaces a NO_PROXY that names the registry and leaves it as is when npm sets nothing or the same list; the npm runNpm starts gets that environment through the guard it runs under (this test fails when runNpm does not build it).

Scope

Components: CLI (the npm commands it runs for itself)

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run --project node over foundation/release/cache.test.mjs (41 passed, 3 new), foundation/release/notices.test.mjs (30 passed) and foundation/release/choose.test.mjs (18 passed).
  • tsc --project tsconfig.strict.json, ESLint and Prettier on the changed files.

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 19, 2026 12:10am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 19, 2026, 12:29 AM UTC

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · b55c82d

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 5.24 MB packed (+1.0 kB); no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: the fix looks right, but one statement in the pull request description does not match the code.

Blocking

  • The description says runNpm is "the one place the CLI starts npm", but the CLI also starts npm in runNpmPackJson (packages/cli/foundation/integrations/pack-state.mjs), in installJscodeshift (packages/cli/assets/codemods/ensure-jscodeshift.mjs) and in this change's own readNpmNoProxy, so please reword it to say that runNpm is 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 noproxy setting. 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_PROXY naming 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 noproxy definition 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 noproxy setting. 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: runNpm is 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 view results). 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 exports map.
  • 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.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pack that integration verify runs (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 noproxy setting. 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_PROXY naming 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_PROXY as the default of its noproxy setting, but npm 11 lets the variable win. Verified: npm's noproxy definition 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 noproxy setting. Verified: cache.mjs:389-392, :407.
  • Claim: before this change runNpm started npm with the run's environment as is. Verified: the base passes no environment of its own.
  • Claim: runNpm is the one runner for the CLI's own cache installs and registry queries. Verified: cache.mjs:509, :537, :1092; no other CLI code runs npm install or npm 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 runNpm runs 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 out integration verify's npm 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 view results). Consistent with npm's source; not reproduced.
  • Claim: regression tests for the setting, the environment and runNpm's guard path, the last failing when runNpm does not build the environment. Verified: cache.test.mjs:1031-1090 pass, and the guard test fails when cache.mjs:442 passes process.env instead.
  • Claim: one defect, no tag-along, no hidden public API or default, no internal context. Verified: the module is outside the package's exports map.
  • 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.

Automated review (maintainer link)

: options.npm
? null
: configuredNoProxy === undefined
? (configuredNoProxy = readNpmNoProxy(npm))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 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.

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 noproxy read under "npm (under npm-guard.mjs)", but readNpmNoProxy starts 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 pack that integration verify runs (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 noproxy setting. 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_PROXY naming the registry sent npm straight to it despite npm's proxy settings. Verified in npm's agent source: the agent drops npm's noproxy when 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_PROXY as the default of its noproxy setting, 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 noproxy setting. Verified: cache.mjs:389-392, :407.
  • Claim: before this change runNpm started npm with the run's environment as is. Verified: the base passes no environment of its own.
  • Claim: runNpm is the one runner for the CLI's own cache installs and registry queries. Verified: cache.mjs:509, :537, :1092; no other CLI code runs npm install or npm view for 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 runNpm runs 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 out integration verify's npm 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 view results). Consistent with npm's source; not reproduced.
  • Claim: regression tests for the setting, the environment and runNpm's guard path, the last failing when runNpm does not build the environment. Verified: cache.test.mjs:1020-1091 pass, and the guard test fails when cache.mjs:442 passes process.env instead.
  • Claim: one defect, no tag-along, no hidden public API or default, no internal context. Verified: the module is outside the package's exports map, 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 six spawnSync sites in cache.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.

Automated review (maintainer link)

'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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

josephfarina added a commit that referenced this pull request Nov 19, 2026
- #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
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12812.

@github-actions
github-actions Bot deleted the josephfarina/npm-honors-its-noproxy branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — b55c82d0 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant