-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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] Installing a package from GitHub appears to send NPM into an indefinite, high CPU usage frenzy #3787
Comments
Thanks for the issue! I've confirmed this happens on the latest npm This seems to point to an issue within arborist as it loops on |
Simple reproduction case:
Or:
More details in npm/arborist#325 |
The fact that it hits this loop while preparing a git dep is a red herring. The root cause is just an install that has this particular shape of dependency graph. |
Fix: #325 Fix: npm/cli#3787 Replacing a peerDep and leaving it to buildIdealTree to do the right thing can lead to infinite regress in some cases. For example: ``` project -> (a) a -> (x, y, j@1) x -> PEER(j@1) y -> PEER(j@2) ``` In this case, when we get to the `j` peer dependency, we find that there's nowhere to place it (since it's relied upon by a dependency at the top level, either x or y), so we replace the conflicted version, and expect that buildIdealTree will find a new home for it. However, the next pass does the same thing, and so on. This patch addresses the problem in the following way. 1. Collect all the peerEntrySets containing the dependency to be replaced. 2. If all of them _can_ be placed deeper in the tree, we remove the conflicting peerEntrySet, and mark all incoming edges as needing re-evaluation. In the case described above, this means that `x` will be removed as well as `j`, and eventually placed under `a`, where there is no conflict. 3. If any peerEntrySet _cannot_ be placed deeper in the tree, then we mark the offending edge as overridden, so that it won't be re-evaluated by buildIdealTree. This properly finds the nested tree fully when it is possible, and prints the appropriate ERESOLVE warning when it is not.
Is there an existing issue for this?
Current Behavior
High CPU usage with no sign of stopping.
Expected Behavior
The package gets installed.
Steps To Reproduce
Environment
The text was updated successfully, but these errors were encountered: