-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Comments
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 ? |
Same issue in my project. With npm 10.8.3 and below everything ok. My dockerfile:
Checked on 5 machines. |
for some reason mine is not showing any delays... ~/workarea/rep $ cat dockerfile
FROM node:18.19-alpine as node
WORKDIR /home/node/frontend
RUN npm install -g npm@10.9.0
RUN npm i -g @angular/cli@17.3.8 --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 npm@10.9.0 3.2s
=> [4/4] RUN npm i -g @angular/cli@17.3.8 --verbose 23.5s
=> exporting to image 0.4s
=> => exporting layers 0.4s
=> => writing image sha256:4b808728df586e52ff67c1be40887acd0af1795376777f9f2123631b7df2f1d8 |
npm registry. 5 machines was in different locations in Poland with different ISP. |
ok then that sounds like it mostly not be registry related. |
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 logs with npm@10.8.3 There is no |
@mi-lchlebowski Do you think this is related to #4028? |
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. |
I'm having the same issue with 10.9.0 when building docker images. |
No. Issue is always in same place. @riceyrice @dirkhekhuisascendtek please add -ddd to IMO it may be related to dns queries. On docker there is no dns cache instead host machine. |
We've been experiencing the same issue. NPM installs from a You can see that npm logs Another thing to note is this line, where it seems it took npmjs.org almost 30 minutes to reply to the advisories call.
|
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). |
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. |
Could be - it froze for around 25 minutes, with a
|
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:
|
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. |
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) |
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. Downgrade to 10.8.3 helps. |
It's really random. I've just done |
Strangely I had a moment today where it suddenly worked. Then I cleared the cache (
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:
It might be interesting, that in the second part there's a size of yallist, which is undefined in the first part: |
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 |
I can confirm a flood of DNS requests (15.000 and more) within a few seconds originating from my system when I run The requests are all PTR requests, e.g. Depending on the local setup these requests might be sent to a provider DNS or at least the local router and could severely affect network performance. In any case they could explain rate-limiting, freezes and other obscure issues.
|
@aleho I can confirm the same behavior with a flood of PTR DNS requests to Edit: The problem with these DNS queries no longer occurs after a downgrade to NPM v10.8.3. Then, only a few of those PTR DNS requests will be sent. |
Could this have been caused by this change 6ca609e or is ping not used during npm install? I tried npm v10.8.3 but I still get a freeze, so the freeze for me is not caused by the DNS queries, if I downgrade version by version it starts working at 10.3.0, I'd like to add that while it's hanging, cpu is at 0% but the timer of the command stops increasing in htop |
@Tofandel as far as I know ping is not used during install. |
Any idea on what I can use to debug this further? I tried the V8 profiler in a setTimeout but apparently it's not just waiting, it's actually completely frozen and the setTimeout doesn't fire once the hang occurs What could cause such a hang where it's the actual node process that froze? |
@Tofandel If you are consistently reproduce the issue at your end and if you want to debug it further at code level, you can setup |
Yes and I found the issue and opened a PR with a fix |
seeing a 25 minute freeze, doesn't respond to SIGTERM as well, only SIGKILL. node: v22.11.0
|
As I've already explained this issue has been located already and a PR is open in both node to fix the root of the issue and npm to implement a workaround There is no need to paste more logs that don't add any significant information to the issue but noise, thank you The issue will be fixed when either one of nodejs/node#55602 or npm/npm-install-checks#120 lands In the meantime you can use |
I encountered the same issue after upgrading from npm 10.8.2 to 10.9.0. When trying to execute npx create-next-app@latest, it froze (the animation stopped).
|
Yes it's the same issue for all of us. |
@Tofandel I am really sorry to bother, anyway
|
Could you add timers to your output to pinpoint when it is getting stuck and use npm 10.9.0, then just post the last 5 lines of the log |
Here you are:
Anyway... I tested on another network environment, different EC2 instance kind, same AMI tough and the issue doesn't appear. @Tofandel just in case, lmk if there is something I can try for you
|
@SleepyDeb as you mention EC2, please take a look at amazonlinux/amazon-linux-2023#840 |
@deki Thanks, that may appear to be the case, as from the logs @SleepyDeb provided and the fact it doesn't get killed with kill -9 (any freeze that doesn't die with -9 is a kernel issue), the idealTree task did complete and it froze before starting the reify task which is unusual (it would normally freeze just after |
FYI: The node fix was just released in 23.3.0 Hopefully it will be backported to the LTS versions soon |
A temporary fix is to just patch your local copy of You can find your node install with echo $(asdf where nodejs)/lib/node_modules/npm/node_modules/npm-install-checks/lib/current-env.js From there you can edit the file and copy in the contents of that patch file. I would leave your editor open so you can hit undo if it breaks. Note: This is directly editing system files, so use caution! It's likely recoverable, but typos or fat fingers will render your npm install non-functional. Be sure to test that the change functions before closing your editor. I do not recommend just blindly |
Yes this is a bit dirty because the report is now generated once at the beginning of a command which could be considered a side effect (but normally treeshaking will only include it only if needed), but the whole process.report is a weirdly built API meant for debugging and not really meant to be used in a normal program But somehow when the call is done in the beginning of the process, this call is very fast, but when it's called after having run a http request (as is currently the case, a single call takes a lot more time to complete, it takes 40s or more on my system when called at the end of npm upgrade) but only a few milliseconds when called at the beginning (this is why it's best to run it outside the function at the beginning of the process as a side effect instead of calling getReport on demand and cache the result) Here is a log of console.time('report') and console.timeEnd('report') before and after the getReport call when run in the end of the upgrade command: ⠼report: 3:10.573 (m:ss.mmm) when run in the beginning of the process at the top level report: 1.943ms This fixes npm hanging npm/cli#4028, npm/cli#7814, npm/cli#7868
This was fixed in npm 10.9.1 (via npm/npm-install-checks#120) |
Is there an existing issue for this?
This issue exists in the latest npm version
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:
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
`
The text was updated successfully, but these errors were encountered: