Skip to content
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

fix: out-of-memory error during peers resolution #8057

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg-manager/resolve-dependencies/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export async function resolveDependencies (
}
}))

console.log('RESOLVE PEERS!')
const {
dependenciesGraph,
dependenciesByProjectId,
Expand Down
15 changes: 14 additions & 1 deletion pkg-manager/resolve-dependencies/src/resolvePeers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export async function resolvePeers<T extends PartialResolvedPackage> (
pathsByNodeIdPromises,
depPathsByPkgId,
peersCache: new Map(),
cachedNodeIds: new Set(),
peerDependencyIssues,
purePkgs: new Set(),
rootDir,
Expand Down Expand Up @@ -317,6 +318,7 @@ async function resolvePeersOfNode<T extends PartialResolvedPackage> (
virtualStoreDirMaxLength: number
peerDependencyIssues: Pick<PeerDependencyIssues, 'bad' | 'missing'>
peersCache: PeersCache
cachedNodeIds: Set<string>
purePkgs: Set<string> // pure packages are those that don't rely on externally resolved peers
rootDir: string
lockfileDir: string
Expand Down Expand Up @@ -433,6 +435,9 @@ async function resolvePeersOfNode<T extends PartialResolvedPackage> (
} else {
ctx.peersCache.set(resolvedPackage.depPath, [cache])
}
for (const cachedNodeId of cache.resolvedPeers.values()) {
ctx.cachedNodeIds.add(cachedNodeId)
}
}

let calculateDepPathIfNeeded: CalculateDepPath | undefined
Expand Down Expand Up @@ -586,6 +591,7 @@ async function resolvePeersOfChildren<T extends PartialResolvedPackage> (
ctx: ResolvePeersContext & {
peerDependencyIssues: Pick<PeerDependencyIssues, 'bad' | 'missing'>
peersCache: PeersCache
cachedNodeIds: Set<string>
virtualStoreDir: string
virtualStoreDirMaxLength: number
purePkgs: Set<string>
Expand Down Expand Up @@ -640,7 +646,14 @@ async function resolvePeersOfChildren<T extends PartialResolvedPackage> (
const { cycles } = analyzeGraph(graph as unknown as Graph)
finishingList.push(...calculateDepPaths.map((calculateDepPath) => calculateDepPath(cycles)))
}
const finishing = Promise.all(finishingList).then(() => {})
const finishing = Promise.all(finishingList).then(() => {
for (const childNodeId of nodeIds) {
if (childNodeId.indexOf('>', 1) < childNodeId.length - 1 && !ctx.cachedNodeIds.has(childNodeId)) {
// console.log('delete', childNodeId)
ctx.dependenciesTree.delete(childNodeId)
}
}
})

const unknownResolvedPeersOfChildren = new Map<string, string>()
for (const [alias, v] of allResolvedPeers) {
Expand Down