mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-26 07:27:20 -04:00
fix: out of memory exception with node-linker=hoisted (#5988)
ref #5909
This commit is contained in:
6
.changeset/cuddly-hounds-unite.md
Normal file
6
.changeset/cuddly-hounds-unite.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/headless": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Fixed out of memory error that sometimes happens when `node-linker` is set to `hoisted`.
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
PackageFilesResponse,
|
||||
StoreController,
|
||||
} from '@pnpm/store-controller-types'
|
||||
import pLimit from 'p-limit'
|
||||
import difference from 'ramda/src/difference'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import rimraf from '@zkochan/rimraf'
|
||||
@@ -19,6 +20,8 @@ import {
|
||||
DependenciesGraph,
|
||||
} from './lockfileToDepGraph'
|
||||
|
||||
const limitLinking = pLimit(16)
|
||||
|
||||
export async function linkHoistedModules (
|
||||
storeController: StoreController,
|
||||
graph: DependenciesGraph,
|
||||
@@ -111,22 +114,27 @@ async function linkAllPkgsInOrder (
|
||||
patchFileHash: depNode.patchFile?.hash,
|
||||
})
|
||||
}
|
||||
const { importMethod, isBuilt } = await storeController.importPackage(depNode.dir, {
|
||||
filesResponse,
|
||||
force: opts.force || depNode.depPath !== prevGraph[dir]?.depPath,
|
||||
keepModulesDir: true,
|
||||
requiresBuild: depNode.requiresBuild || depNode.patchFile != null,
|
||||
sideEffectsCacheKey,
|
||||
})
|
||||
if (importMethod) {
|
||||
progressLogger.debug({
|
||||
method: importMethod,
|
||||
requester: opts.lockfileDir,
|
||||
status: 'imported',
|
||||
to: depNode.dir,
|
||||
// Limiting the concurrency here fixes an out of memory error.
|
||||
// It is not clear why it helps as importing is also limited inside fs.indexed-pkg-importer.
|
||||
// The out of memory error was reproduced on the teambit/bit repository with the "rootComponents" feature turned on
|
||||
await limitLinking(async () => {
|
||||
const { importMethod, isBuilt } = await storeController.importPackage(depNode.dir, {
|
||||
filesResponse,
|
||||
force: opts.force || depNode.depPath !== prevGraph[dir]?.depPath,
|
||||
keepModulesDir: true,
|
||||
requiresBuild: depNode.requiresBuild || depNode.patchFile != null,
|
||||
sideEffectsCacheKey,
|
||||
})
|
||||
}
|
||||
depNode.isBuilt = isBuilt
|
||||
if (importMethod) {
|
||||
progressLogger.debug({
|
||||
method: importMethod,
|
||||
requester: opts.lockfileDir,
|
||||
status: 'imported',
|
||||
to: depNode.dir,
|
||||
})
|
||||
}
|
||||
depNode.isBuilt = isBuilt
|
||||
})
|
||||
}
|
||||
return linkAllPkgsInOrder(storeController, graph, prevGraph, deps, dir, opts)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user