Closed JanStureNielsen closed 6 months ago
Pretty sure your dependence on “18” is a typo (not sure if it’s relevant) also, your engines.npm isn’t using ^ and doesn’t match the npm version you’re reporting.
Thanks, @ljharb -- report fixed; same result.
I can reproduce this myself under WSL with half the host's RAM available (8 GB) and it's quite a serious regression especially since these npm versions ship with Node.js LTS.
npm v10.2.4 works fine that I could try with the Node.js 20.11.1 docker image. v20.12.0 which has npm 10.5.0 has the memory leak issue which brings down my machine since it starts swapping.
Could someone have a look at it please?
I got the same problem I believe with: https://github.com/npm/cli/issues/7351
We have identified the primary culprit here, it's an unbound cache that saves all packuments in Arborist. Because we now fetch full packuments for all situations, this is causing issues on what would otherwise have been a working system configuration.
This was always technically a problem. We are doing some metrics so we know exactly the right way to fix this, and fix it in a way that hopefully even benefits those running on more memory limited environments.
You can see some initial proof of concept testing at https://github.com/npm/cli/pull/7463.
Ultimately we plan on putting in an lru-cache
instead of an unbound Map
, and we are doing analytics to be able to let npm make a decision about how large to let that cache get.
There is also an existing bug that has up until now not meaningfully impacted npm, and that is when the cache has stale data the packument._contentLength
attribute is 0
. This bug will also have to be fixed so that in those situations npm still knows the size of the packument.
Thank you for the update, @wraithgar -- have you identified a root-cause commit for this regression?
Yes, as I said.
Because we now fetch full packuments for all situations
https://github.com/npm/cli/pull/7126
However it must be reiterated this was always a problem, it just didn't manifest as commonly on systems with plenty of memory. This commit pushed the line much lower, is all.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
It appears the latest dependency resolving algorithm is taking more memory than before. The following fails:
as does
with
I have described this issue on SO as well.
Expected Behavior
The following succeeds:
as does:
Steps To Reproduce
or
with
Environment
force = true
; node bin location = /home/jan/.nvm/versions/node/v18.19.1/bin/node ; node version = v18.19.1 ; npm local prefix = /home/jan/src/my-ui ; npm version = 10.4.0 ; cwd = /home/jan/src/my-ui ; HOME = /home/jan ; Run
npm config ls -l
to show all defaults.