Skip to content

Conversation

beyondkmp
Copy link
Collaborator

@beyondkmp beyondkmp commented Feb 12, 2025

fix #8857

Root cause
It's caused by #8851

How to fix

In situations like issue #8851, a skipCircularDeps parameter should be added. This way, when traversing the tree, only the values inside are retrieved without further traversal, thus avoiding an infinite loop.

Copy link

changeset-bot bot commented Feb 12, 2025

🦋 Changeset detected

Latest commit: 6055b5b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
app-builder-lib Patch
dmg-builder Patch
electron-builder-squirrel-windows Patch
electron-builder Patch
electron-forge-maker-appimage Patch
electron-forge-maker-nsis-web Patch
electron-forge-maker-nsis Patch
electron-forge-maker-snap Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@beyondkmp beyondkmp requested a review from mmaietta February 13, 2025 02:49
@beyondkmp beyondkmp changed the title fix: skip circular deps fix: Detected circular dependencies and add debug logs for nodeModulesCollector Feb 13, 2025
@beyondkmp beyondkmp merged commit 3fe27d7 into electron-userland:master Feb 14, 2025
15 checks passed
beyondkmp added a commit to beyondkmp/electron-builder that referenced this pull request Apr 10, 2025
fix electron-userland#9000
and electron-userland#9006

**Root Cause**

It directly copies `node_modules` into the app directory and removes
`devDependencies` from `package.json`. This way, `npm list` can retrieve
all dependencies. However, during the lookup process, if there are
duplicate dependency packages, some `dependencies` in `npm` may be
empty. A previous
fix(electron-userland#8864 )
introduced the concept of `implicit dependencies` to address this issue,
but it only handled the first level of `implicit dependencies`. If
`implicit dependencies` themselves contain further `implicit
dependencies`, the problem described in electron-userland#9000 will occur.


**How to fix**

The current approach directly searches the `parsedTree` and updates the
global `this.productionGraph`. If there are cases where `dependencies`
are empty, it retrieves the same dependency from `allDependencies` and
performs a lookup for sub-dependencies. If the dependency already exists
in `this.productionGraph`, no further lookup is performed. Additionally,
to prevent infinite loops, an empty array is set before searching for
sub-dependencies.

Now that two tree lookup has been eliminated, there will be a certain
improvement in performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

26.0.6 node-module-collector RangeError: Maximum call stack size exceeded
2 participants