[BUG] npx -y takes 70 s offline before running a cached package (about 5 min when packets are dropped)
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 67/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- JavaScript
- スター
- 10.3k
- フォーク
- 5k
- 平均マージ
- 4日 11時間
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
npm/cli のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 2 日以内に返信
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endings対応中かも @saruk-vedant が 7 日前に担当しました。 オープンBug Needs Triage Triage Requested
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
[BUG] npm pkg delete removes the first array item for a nonexistent property対応中かも @drawliin が 42 日前に担当しました。 オープンcmd:delete Priority 3
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 2 日以内に返信
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings logged再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンEngineering Priority 1
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 2 日以内に返信
-
`npm audit signatures` does not report how many packages it skipped for want of registry keys対応中かも @greenlincoln05 が 63 日前に担当しました。 オープンPriority 3
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
githubnext/gh-aw-workshop#6332 ·
メンテナーはふだん 1 日以内に返信
-
App Designer bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
avniproject/avni-webapp#1858 ·
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 96/100
hiero-ledger/hiero-sdk-js#4834 ·
メンテナーはふだん 1 日以内に返信
-
[组件名称] 描述问题的标题オープン🐞 bug 🧐 unconfirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Tencent/tdesign-miniprogram#4744 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Y-axis tooltip hides near the bottom of the plot while the y crosshair stays visible対応中かも @lazerg が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apexcharts/apexcharts.js#5449 ·
メンテナーはふだん 3 日以内に返信