fix(list): limit manifest reads for large workspaces (#11692)

This commit is contained in:
mehmet turac
2026-05-24 12:45:40 +03:00
committed by GitHub
parent 572842a039
commit a456dc78fb
4 changed files with 23 additions and 7 deletions

View File

@@ -0,0 +1,7 @@
---
"@pnpm/deps.inspection.list": patch
"@pnpm/workspace.project-manifest-reader": patch
"pnpm": patch
---
Limit concurrent project manifest reads while listing large workspaces to avoid `EMFILE` errors.

3
pnpm-lock.yaml generated
View File

@@ -9638,6 +9638,9 @@ importers:
json5:
specifier: 'catalog:'
version: 2.2.3
p-limit:
specifier: 'catalog:'
version: 7.3.0
parse-json:
specifier: 'catalog:'
version: 8.3.0

View File

@@ -41,6 +41,7 @@
"fast-deep-equal": "catalog:",
"is-windows": "catalog:",
"json5": "catalog:",
"p-limit": "catalog:",
"parse-json": "catalog:",
"read-yaml-file": "catalog:",
"strip-bom": "catalog:"

View File

@@ -9,6 +9,7 @@ import { writeProjectManifest } from '@pnpm/workspace.project-manifest-writer'
import detectIndent from 'detect-indent'
import equal from 'fast-deep-equal'
import isWindows from 'is-windows'
import pLimit from 'p-limit'
import { readYamlFile } from 'read-yaml-file'
import {
@@ -18,15 +19,19 @@ import {
export type WriteProjectManifest = (manifest: ProjectManifest, force?: boolean) => Promise<void>
const limitProjectManifestReads = pLimit(4)
export async function safeReadProjectManifestOnly (projectDir: string): Promise<ProjectManifest | null> {
try {
return await readProjectManifestOnly(projectDir)
} catch (err: any) { // eslint-disable-line
if ((err as NodeJS.ErrnoException).code === 'ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND') {
return null
return limitProjectManifestReads(async () => {
try {
return await readProjectManifestOnly(projectDir)
} catch (err: any) { // eslint-disable-line
if ((err as NodeJS.ErrnoException).code === 'ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND') {
return null
}
throw err
}
throw err
}
})
}
export async function readProjectManifest (projectDir: string): Promise<{