npm cannot fetch from ANY local/loopback HTTP registry stub: no TCP connection is opened, request times out (FETCH_ERROR) — make-fetch-happen reproduces it standalone; node's own http clients work
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, node.js
- Lĩnh vực
- backend, networking
Hướng nghiên cứu
Start by reproducing the standalone [email protected] case from the issue, then trace the request through make-fetch-happen and minipass-fetch, especially minipass-fetch/lib/index.js and getNodeRequestOptions in request.js:239-242. Compare the agent/fetch path with the working plain http.request case and the reported socket events. Done means npm and standalone make-fetch-happen reach the local HTTP stub and receive its response without timing out.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Current Behavior
npm view / npm ping against a local HTTP registry stub (a plain http.createServer answering every request with 200) never opens a TCP connection to the stub and dies with FETCH_ERROR / request-timeout after the fetch timeout (~5s with --fetch-timeout=5000). With default flags the request just stalls (observed >30s). node's own clients against the same stub work instantly. The failure is identical on every box we tested — Linux and macOS.
Expected Behavior
npm should connect to and fetch from the local registry stub, as node's own http.request/fetch do.
Steps to Reproduce
Self-contained: start a stub in one node process, run npm view against it.
// stub.mjs — answers any request with a minimal packument
import http from "node:http";
let hits = 0, conns = 0;
http.createServer((req, res) => {
hits++;
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify({ _id: "left-pad", name: "left-pad", "dist-tags": { latest: "1.0.0" }, versions: { "1.0.0": { name: "left-pad", version: "1.0.0" } } }));
}).on("connection", () => conns++)
.listen(0, "[redacted:ip]", () => console.log(`stub http://[redacted:ip]:${stub.address().port} — watch hits/conns here`));
npm view left-pad@^1.0.0 version --json --registry http://[redacted:ip]:<port> --fetch-retries=0 --fetch-timeout=5000
# -> ~5.2s, exit 1: npm error code FETCH_ERROR / "network timeout at: ..."
# stub-side: hits and TCP conns UNCHANGED — npm never connected
node -e 'fetch("http://[redacted:ip]:<port>/left-pad").then(r => console.log(r.status))'
# -> 200 in single-digit ms — node's own client is fine
npm ping --registry http://[redacted:ip]:<port> --fetch-retries=0 --fetch-timeout=5000
# -> same FETCH_ERROR, stub still never sees a socket
Layer isolation (why we think it is make-fetch-happen, not npm wiring)
All of this in one session, npm 10.9.8 bundled tree:
- node
fetchandhttp.getagainst the stub: HTTP 200 in 3–25ms (stub sees the connection). - npm CLI (
view,ping):FETCH_ERRORat ~5.2s with--fetch-timeout=5000; stub-side TCP connection count and request bytes: 0.--loglevel=sillyshowsnpm http fetch GET ... attempt 1 failed with FETCH_ERROR, typerequest-timeout, stack insideminipass-fetch/lib/index.jstimeout timer. - [email protected] (npm's bundled copy) driven directly from a plain node script — no npm, no npmrc, no config:
Identical hang. Instrumentingconst mfh = makeRequire("<npm-install>/node_modules/make-fetch-happen/package.json")("make-fetch-happen"); await mfh("http://[redacted:ip]:<port>/", { timeout: 5000 }); // -> FETCH_ERROR at 5006ms, stub saw 0 connectionshttp.requestinside that child: the options are well-formed enough (hostname: "[redacted:ip]",port,path: "/"; note minipass-fetch'sgetNodeRequestOptionsalso setshost: parsedURL.hostwhich containsip:port— request.js:239-242 — but plain node handles that shape fine when hostname is present), the request fires'socket'with a socket that reportsremoteAddress/remotePortas the stub andconnecting: false— yet the stub never receives the connection.'error'never fires; the minipass-fetchrequest-timeouttimer is what ends it. - Plain node
http.requestwith the exact same options shape (including thehost: "ip:port"quirk and an equivalent keepAlive agent + extras): HTTP 200 in 2–33ms every time. So the fault is not the options shape, not node's http stack, and not npm's CLI wiring — it is inside make-fetch-happen's agent/fetch layer. - Controls: real registry fine (
npm view left-pad@^999.0.0→ fastE404round-trip, 270–570ms); closed loopback port → fastECONNREFUSED(216–355ms) — so npm's client does attempt connects and can see refusals; it is specifically the listening local server case that silently never connects. - Not a proxy/npmrc/env artifact:
npm config get proxy/https-proxy→ null; noHTTP(S)_PROXY/npm_config_*in env on the failing legs;.npmrcempty;http://localhost:<port>fails identically tohttp://[redacted:ip]:<port>.
Environment
- npm 10.9.8 / node 22.23.1 / macOS arm64 (Darwin 27)
- npm 10.9.9 / node 22.23.3 / Linux x64 (GitHub-hosted ubuntu-latest, Linux 6.17)
- npm 10.9.8 / node 22.23.2 / macOS arm64 (GitHub-hosted macos-14, Darwin 23.6)
- Bundled layer: [email protected], [email protected]
All three boxes fail byte-for-byte identically, including the standalone make-fetch-happen repro on box 1.
Why this matters
The "spin a stub registry and point npm at it" recipe is the standard way to make npm-behavior pins hermetic (E404 vs E5xx vs ECONNREFUSED classification, packument shapes). On current npm it silently cannot work on any of our Linux or macOS environments — the stub never sees a socket and the caller times out, which reads as a flake/hang rather than a clear error.
Happy to provide the full instrumented-child receipts or test candidate fixes.
- Ngôn ngữ chính
- JavaScript
- Star
- 10.3k
- Fork
- 5k
- Merge trung bình
- 4 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 26
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của npm/cli
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endingsCó thể đã có người làm @saruk-vedant đã nhận 7 ngày trước. Đang mởBug Needs Triage Triage Requested
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyCó thể đã có người làm @drawliin đã nhận 42 ngày trước. Đang mởcmd:delete Priority 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 2 ngày
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởEngineering Priority 1
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 2 ngày
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysCó thể đã có người làm @greenlincoln05 đã nhận 63 ngày trước. Đang mởPriority 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
docs: add SECURITY.md vulnerability reporting policyCó thể đã có người làm @AK-Lmn đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
flisk-sh/linux2wasm#12 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
possible bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Mintplex-Labs/anything-llm#7388 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 60/100
Maintainer thường phản hồi trong vòng 1 ngày
-
v6: Minified bootstrap.min.css is missing header infoCó thể đã có người làm @lazerg đã nhận hôm nay. Đang mởbug build confirmed has-pr v6
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[workshop-sync] workshop/side-quest-26-01-forecast-costs.md: forecast default history window is inaccurateCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdocumentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
githubnext/gh-aw-workshop#6332 ·
Maintainer thường phản hồi trong vòng 1 ngày