Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] <Freezes during npm install> #7814

Open
2 tasks done
SahDhiraj opened this issue Oct 4, 2024 · 21 comments
Open
2 tasks done

[BUG] <Freezes during npm install> #7814

SahDhiraj opened this issue Oct 4, 2024 · 21 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@SahDhiraj
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

While running the command npm install with the latest version (V10.9.0), the installation pauses and does not proceed further.

To resolve this, I have attempted the following steps:

  1. Cleared the npm cache using npm cache clean --force.
  2. Restarted both my PC and Visual Studio Code.
  3. Deleted the package-lock.json file and the node_modules directory.
    But none of these worked.

Expected Behavior

Sould have installed the dependencies and created package-lock.json and node_modules.

Steps To Reproduce

Environment: Using Visual Studio Code with Node.js version 20.13.1.
React and TypeScript: The project uses React version 18.2.0 and TypeScript version 5.3.3.
Command: When I run npm install, the process appears to be loading continuously without any further progress.

Environment

  • npm: 10.9.0
  • Node.js: 20.13.1
  • OS Name: Ubuntu 20.04.6 LTS
  • npm config:
    `
@SahDhiraj SahDhiraj added Bug thing that needs fixing Needs Triage needs review for next steps labels Oct 4, 2024
@milaninfy
Copy link
Contributor

This type of behaviour is not easy to track without reproduction steps or other details. It would be helpful for triaging this issue if you can provide details like package.json, package-lock, npm config, logs and command used.

Is it happening for all your project or a specific one ?

@mi-lchlebowski
Copy link

mi-lchlebowski commented Oct 7, 2024

Same issue in my project. With npm 10.8.3 and below everything ok. My dockerfile:

FROM node:18.19-alpine as node

WORKDIR /home/node/frontend

RUN npm install -g npm@latest
RUN npm i -g @angular/[email protected]

RUN npm i -g @angular/[email protected] takes 90 minutes. Last few runs from 3 days:
90' 18".
90' 17",
90' 23",
90' 26".

FROM node:18.19-alpine as node

WORKDIR /home/node/frontend

RUN npm install -g [email protected]
RUN npm i -g @angular/[email protected]

RUN npm i -g @angular/[email protected] takes few seconds

Checked on 5 machines.

@milaninfy
Copy link
Contributor

for some reason mine is not showing any delays...
are you using npm registry or custom hosted registry settings ?

~/workarea/rep $ cat dockerfile
FROM node:18.19-alpine as node

WORKDIR /home/node/frontend

RUN npm install -g [email protected]
RUN npm i -g @angular/[email protected] --verbose
/workarea/rep $ docker build .
[+] Building 27.6s (8/8) FINISHED                                                                                                                                   docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                0.0s
 => => transferring dockerfile: 173B                                                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/node:18.19-alpine                                                                                                                0.5s
 => [internal] load .dockerignore                                                                                                                                                   0.0s
 => => transferring context: 2B                                                                                                                                                     0.0s
 => [1/4] FROM docker.io/library/node:18.19-alpine@sha256:c7620fdecfefb96813da62519897808775230386f4c8482e972e37b8b18cb460                                                          0.0s
 => CACHED [2/4] WORKDIR /home/node/frontend                                                                                                                                        0.0s
 => [3/4] RUN npm install -g [email protected]                                                                                                                                             3.2s
 => [4/4] RUN npm i -g @angular/[email protected] --verbose                                                                                                                               23.5s
 => exporting to image                                                                                                                                                              0.4s
 => => exporting layers                                                                                                                                                             0.4s
 => => writing image sha256:4b808728df586e52ff67c1be40887acd0af1795376777f9f2123631b7df2f1d8     

@mi-lchlebowski
Copy link

npm registry.

5 machines was in different locations in Poland with different ISP.

@milaninfy
Copy link
Contributor

ok then that sounds like it mostly not be registry related.
if possible, will you be able to share install log files from this command run where it takes time RUN npm i -g @angular/[email protected] -ddd in your docker step ?

@mi-lchlebowski
Copy link

It seems problem is related to high dns pool rate. I have pi-hole as dns in my network. In pi-hole log I have information about rate limiting for my IP: "Client 192.168.8.113 has been rate-limited (current config allows up to 1000 queries in 60 seconds)". It happens only in one moment during install - before line reify moves {} appears in log.
I chagned my dns to google and cloudflare ommiting pi-hole. Result in the attachment. Today times are much shorter but still too long. Below logs.
docker_build_cloudflare_dns.log
docker_build_google_dns.log
docker_build_pihole_cloudflare.log

logs with [email protected]
docker_build_npm_10_8_3.log

There is no reify moves {}

@pfeileon
Copy link

pfeileon commented Oct 9, 2024

@mi-lchlebowski Do you think this is related to #4028?

@riceyrice
Copy link

I've seen something like this with npm 10.9.0 when run by docker build. Doesn't occur on the host machine. Doesn't occur with npm 10.8.3. Workaround was to pin npm to 10.8.

@dirkhekhuisascendtek
Copy link

I'm having the same issue with 10.9.0 when building docker images.

@mi-lchlebowski
Copy link

mi-lchlebowski commented Oct 10, 2024

@mi-lchlebowski Do you think this is related to #4028?

No. Issue is always in same place.

@riceyrice @dirkhekhuisascendtek please add -ddd to npm i and paste log. Maybe this will be reify move too?

IMO it may be related to dns queries. On docker there is no dns cache instead host machine.

@OrfeasZ
Copy link

OrfeasZ commented Oct 11, 2024

We've been experiencing the same issue. NPM installs from a node:20-bookworm container (with both IPv4 and IPv6 connectivity, both working correctly) sometimes take several hours to complete. I've attached a log below (with silly debug logging) of an install that took upwards of 5 hours.

You can see that npm logs npm silly idealTree buildDeps at 5 seconds, and the next log line is at 20990 seconds (after 5.8 hours).

Another thing to note is this line, where it seems it took npmjs.org almost 30 minutes to reply to the advisories call.

npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 1778840ms

npm-slow.log

@codeart1st
Copy link

Same here. Only get the problems with our corporate VPN. Moving back to NPM 10.8.0 helps. Goging back to 10.9.0 breaks again. Also 10.9.0 works in our office network (without VPN).
Also disabled auditing with audit=false, but the problems described above are still there.

@Clement-Z4RM
Copy link

I had the same issue when I upgraded NPM to v10.9: it freezes (the animations stops) after a while when running commands installing packages.
I downgraded to v10.8.3 and no longer have this problem.

@riceyrice
Copy link

riceyrice commented Oct 11, 2024

@riceyrice please add -ddd to npm i and paste log. Maybe this will be reify move too?

Could be - it froze for around 25 minutes, with a reify moves output just after, or maybe that fetch GET has a very silly timeout!?

#15 [base base 10/14] RUN npm ci -ddd
#15 0.441 npm verbose cli /usr/bin/node /usr/bin/npm
#15 0.441 npm info using [email protected]
#15 0.441 npm info using [email protected]
#15 0.441 npm silly config load:file:/usr/lib/node_modules/npm/npmrc
#15 0.441 npm silly config load:file:/app/.npmrc
#15 0.441 npm silly config load:file:/root/.npmrc
#15 0.441 npm silly config load:file:/usr/etc/npmrc
#15 0.445 npm verbose title npm ci
#15 0.445 npm verbose argv "ci" "--loglevel" "silly"
#15 0.445 npm verbose logfile logs-max:10 dir:/root/.npm/_logs/2024-10-11T08_19_02_954Z-
#15 0.447 npm verbose logfile /root/.npm/_logs/2024-10-11T08_19_02_954Z-debug-0.log
#15 0.643 npm silly logfile done cleaning log files
#15 0.681 npm silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
#15 0.888 npm silly idealTree buildDeps
#15 1566.7 npm http fetch GET https://registry.npmjs.org/npm attempt 1 failed with ECONNRESET
#15 1566.7 npm silly reify moves {}

npm-ci-ddd.txt

@riceyrice
Copy link

Aha, I was writing up network details in case this is some DNS thing: Docker 4.34.2 (167172) on Windows 11 with WSL2 backend, Tailscale VPN (disconnected). Connected the VPN and the delay is 5s instead:

#15 0.586 npm silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
#15 0.796 npm silly idealTree buildDeps
#15 5.310 npm silly reify moves {}

@milaninfy
Copy link
Contributor

Since it's not reproducible/traced even based on logs, Please provide as much information as you can, this would help greatly. just like attached Logs ( Thanks for that ), Operating system information, versions of tech stack used, configs, package file etc.

@Tofandel
Copy link

Tofandel commented Oct 14, 2024

I have the same issue and I already explained it in #4028 (comment)

Since I can reproduce it 100% of the time after npm 10.4.0, I could help providing a repro because I'm at loss on debugging this further (but because it happens only when there is a lot of dependencies it cannot really be a minimal repro, I can just copy paste my package.json from a project that has it)

@jeffrson
Copy link

jeffrson commented Oct 17, 2024

Happened to me in WSL after upgrade to NodeJS 22.10.0, which comes with npm 10.9.0, while nvm installs packages listed in ~/.nvm/default-packages.
Example for package that causes npm to hang is pm2: npm i -g pm2

Downgrade to 10.8.3 helps.

@Clement-Z4RM
Copy link

Example for package that causes npm to hang is pm2: npm i -g pm2

It's really random. I've just done npm i -g pm2 (with npm 10.9.0 / Node 22.10.0), and it worked.
I think that would be more likely to happen when installing a lot of packages (like npm i in a "big" project).

@jeffrson
Copy link

jeffrson commented Oct 17, 2024

Strangely I had a moment today where it suddenly worked. Then I cleared the cache (npm cache clean --force) and the problem reappeared. Here are the last lines of '-ddd' output:

npm silly packumentCache full:https://registry.npmjs.org/git-sha1 set size:undefined disposed:false
npm http fetch GET 200 https://registry.npmjs.org/bodec 50ms (cache miss)
npm silly packumentCache full:https://registry.npmjs.org/bodec set size:undefined disposed:false
npm silly placeDep node_modules/pm2 [email protected] OK for: [email protected] want: ^0.1.0
npm silly placeDep node_modules/pm2 [email protected] OK for: [email protected] want: ^0.1.2
npm silly placeDep node_modules/pm2 [email protected] OK for: [email protected] want: ^0.1.2
npm silly placeDep node_modules/pm2 [email protected] OK for: [email protected] want: ^0.2.5
npm silly placeDep node_modules/pm2/node_modules/@pm2/agent [email protected] OK for: [email protected] want: ^6.0.0
npm silly fetch manifest yallist@^4.0.0
npm silly packumentCache full:https://registry.npmjs.org/yallist cache-miss
npm http fetch GET 200 https://registry.npmjs.org/yallist 47ms (cache miss)
npm silly packumentCache full:https://registry.npmjs.org/yallist set size:undefined disposed:false
npm silly placeDep node_modules/pm2 [email protected] OK for: [email protected] want: ^4.0.0
npm silly placeDep node_modules/pm2 [email protected] OK for: [email protected] want: ^4.17.14
npm silly placeDep node_modules/pm2/node_modules/@pm2/io [email protected] OK for: [email protected] want: ^6.0.0

Then it wait's for more than an hour. Now when I press Ctrl-C and try another time it works. Here's how the log continues, with some overlapping lines:

npm silly fetch manifest yallist@^4.0.0
npm silly packumentCache full:https://registry.npmjs.org/yallist cache-miss
npm http fetch GET 200 https://registry.npmjs.org/yallist 2ms (cache hit)
npm silly packumentCache full:https://registry.npmjs.org/yallist set size:34610 disposed:false
npm silly placeDep node_modules/pm2 [email protected] OK for: [email protected] want: ^4.0.0
npm silly placeDep node_modules/pm2 [email protected] OK for: [email protected] want: ^4.17.14
npm silly placeDep node_modules/pm2/node_modules/@pm2/io [email protected] OK for: [email protected] want: ^6.0.0
npm silly reify mark retired [
npm silly reify   '/home/user/.nvm/versions/node/v22.10.0/lib/node_modules/pm2',
npm silly reify   '/home/user/.nvm/versions/node/v22.10.0/bin/pm2',
npm silly reify   '/home/user/.nvm/versions/node/v22.10.0/bin/pm2-dev',
npm silly reify   '/home/user/.nvm/versions/node/v22.10.0/bin/pm2-docker',
npm silly reify   '/home/user/.nvm/versions/node/v22.10.0/bin/pm2-runtime'
npm silly reify ]
npm silly reify moves {
npm silly reify   '/home/user/.nvm/versions/node/v22.10.0/lib/node_modules/pm2': '/home/user/.nvm/versions/node/v22.10.0/lib/node_modules/.pm2-170ltMvY',

It might be interesting, that in the second part there's a size of yallist, which is undefined in the first part:
npm silly packumentCache full:https://registry.npmjs.org/yallist set size:34610 disposed:false

@Edwardveb
Copy link

Hey, I have also noticed this bug in one of my solutions, but it seems to struggle only with older packages, as projects with up to date stuff don't seem to be affected. In my windows workstation environment in cmd everything installs and builds fine, but in docker build on the same computer, the older solutions hangs, it takes 45 minutes for npm i step, but it goes thru and doesn't crash, so I assume there is some spaghetti involved.

To people struggling with this bug in docker, an easy temporary fix is to change in the dockerfile
FROM node:latest AS node
to
FROM node:18 AS node
And then it seems to install and build as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests