Skip to content

Commit f73d07f

Browse files
Trevor BurnhamTrevorBurnham
Trevor Burnham
authored andcommitted
fix(arborist): check placed node children for missing deps (#7746)
This addresses an edge case where a dep could be placed in the tree with unsatisfied indirect dependencies (see test case).
1 parent e674987 commit f73d07f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+46386
-14973
lines changed

workspaces/arborist/lib/arborist/build-ideal-tree.js

+4
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,12 @@ This is a one-time fix-up, please be patient...
988988
}
989989

990990
// lastly, also check for the missing deps of the node we placed,
991+
// as well as any missing deps of the new node's children,
991992
// and any holes created by pruning out conflicted peer sets.
992993
this.#depsQueue.push(placed)
994+
for (const child of placed.children.values()) {
995+
this.#depsQueue.push(child)
996+
}
993997
for (const dep of pd.needEvaluation) {
994998
this.#depsSeen.delete(dep)
995999
this.#depsQueue.push(dep)

workspaces/arborist/test/arborist/reify.js

+9
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,15 @@ t.test('update a node without updating a child that has bundle deps', t => {
539539
}))
540540
})
541541

542+
t.only('restore missing parent while preserving child node', async t => {
543+
const path = fixture(t, 'lockfile-with-missing-parent')
544+
await reify(path)
545+
const parentPath = `${path}/node_modules/globby`
546+
t.equal(fs.statSync(`${parentPath}/package.json`).isFile(), true, 'parent has package.json')
547+
const childPath = `${path}/node_modules/globby/node_modules/minimatch`
548+
t.equal(fs.statSync(`${childPath}/package.json`).isFile(), true, 'child has package.json')
549+
})
550+
542551
t.test('optional dependency failures', t => {
543552
const cases = [
544553
'optional-dep-tgz-missing',

workspaces/arborist/test/fixtures/lockfile-with-missing-parent/package-lock.json

+187
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "lockfile-with-missing-parent",
3+
"version": "1.0.0",
4+
"dependencies": {
5+
"glob": "7.1.6",
6+
"globby": "1.2.0",
7+
"minimatch": "3.0.3"
8+
}
9+
}

0 commit comments

Comments
 (0)