[BUG] npx -y takes 70 s offline before running a cached package (about 5 min when packets are dropped)
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 67/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Start with workspaces/libnpmexec/lib/index.js and inspect the getManifest call that uses preferOnline: true; compare its behavior with --prefer-offline and the reported cache fallback. Reproduce with a cached package and an unreachable registry, then check that npx starts it promptly while preserving normal online behavior. The issue gives timings and reproduction steps but does not name a test file.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is there an existing issue for this?
- I have searched the existing issues. #7295 is related: npx re-checks the registry on every run. This issue is about how long that check takes when the registry can't be reached.
This issue exists in the latest npm version
- I measured on npm 11.2.0. On npm 12.2.3,
workspaces/libnpmexec/lib/index.jsstill fetches the manifest withpreferOnline: true(line 30).
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
npx -y <package> always fetches the package's manifest from the registry, even when the package is already in the npx cache: getManifest in libnpmexec passes preferOnline: true. When the registry can't be reached, npm's fetch retries run first, and only then does npx fall back to the cached copy and start the package. That takes 70 s. When packets are dropped (a captive portal or a firewall), it takes about 5 minutes.
This matters for MCP servers in particular. Most MCP client configurations start their servers with npx -y <server>, so offline every agent start waits over a minute for each server, and clients with shorter startup timeouts give up first.
Measured with @modelcontextprotocol/server-memory, already in the npx cache: the time from starting it until it answers the MCP initialize request over stdio. To make the registry unreachable without changing any configuration, I set npm_config_https_proxy for the command only.
| Registry unreachable (5 alternating rounds) | Median | Range |
|---|---|---|
npx -y |
70,408 ms | 70,382–70,478 |
npm_config_fetch_retries=0 npx -y |
433 ms | 372–567 |
npx -y --prefer-offline |
379 ms | 351–400 |
| Other failures (one run each) | npx -y |
--prefer-offline |
|---|---|---|
DNS fails (proxy proxy.invalid) |
70.4 s | 0.38 s |
Connection refused (proxy 127.0.0.1:9) |
70.7 s | 0.55 s |
Packets dropped (proxy 10.255.255.1:8080) |
295.5 s | 0.34 s |
With the registry set to registry.invalid (no proxy), it fails after 70.2 s, so a DNS failure gets the same retries. That run fails only because nothing is cached under that URL.
Expected Behavior
When the package is in the cache and the registry can't be reached, npx runs the cached version quickly. For example, it could skip retries for DNS failures and refused connections during this freshness check, or give the check a short timeout.
Steps To Reproduce
- Online, run an MCP server once so it's cached:
npx -y @modelcontextprotocol/server-memory. - Make the registry unreachable, for example with
npm_config_https_proxy=http://proxy.invalid:8080for that command, or by disconnecting from the network. - Start it again with
npx -y @modelcontextprotocol/server-memoryand send aninitializerequest on stdin. The reply arrives after about 70 s. - Repeat with
--prefer-offlineornpm_config_fetch_retries=0: the reply arrives in about 0.4 s.
Environment
- npm: 11.2.0 (the same
preferOnline: truein 12.2.3) - Node.js: 22.14.0
- OS Name: macOS 14.2.1 (Apple silicon)
- System Model Name: Apple silicon Mac
- npm config: defaults
Measured with wits. I used an AI assistant to help investigate and write this up; the numbers are from the runs described above.
- Lingua principale
- JavaScript
- Stelle
- 10.3k
- Fork
- 5k
- Merge medio
- 4g 11h
- PR unite (30g)
- 26
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di npm/cli
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endingsForse già presa @saruk-vedant l’ha presa 7 giorni fa. ApertaBug Needs Triage Triage Requested
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyForse già presa @drawliin l’ha presa 42 giorni fa. Apertacmd:delete Priority 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 2 giorni
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaEngineering Priority 1
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
I maintainer di solito rispondono entro 2 giorni
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysForse già presa @greenlincoln05 l’ha presa 63 giorni fa. ApertaPriority 3
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
Issue simili
-
docs: add SECURITY.md vulnerability reporting policyForse già presa @AK-Lmn l’ha presa oggi. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
flisk-sh/linux2wasm#12 ·
I maintainer di solito rispondono entro 1 giorno
-
possible bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Mintplex-Labs/anything-llm#7388 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 60/100
I maintainer di solito rispondono entro 1 giorno
-
v6: Minified bootstrap.min.css is missing header infoForse già presa @lazerg l’ha presa oggi. Apertabug build confirmed has-pr v6
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
githubnext/gh-aw-workshop#6332 ·
I maintainer di solito rispondono entro 1 giorno