Skip to content

Commit 3b92c1d

Browse files
fix(api): reuse single pLimit instance across recursive findI18nDirectories
Each recursive call was creating a new pLimit(8), defeating the global concurrency cap. Pass the limiter as a parameter so all recursion levels share one queue. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b9028f8 commit 3b92c1d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

packages/api/src/i18n/loaders/extension-json.loader.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class ExtensionJsonLoader extends I18nLoader implements OnModuleDestroy {
163163
const i18nDirectories = (
164164
await Promise.all(
165165
extensionRootPaths.map((rootPath) =>
166-
fsLimit(() => this.findI18nDirectories(rootPath)),
166+
fsLimit(() => this.findI18nDirectories(rootPath, fsLimit)),
167167
),
168168
)
169169
).flat();
@@ -180,14 +180,16 @@ export class ExtensionJsonLoader extends I18nLoader implements OnModuleDestroy {
180180
);
181181
}
182182

183-
private async findI18nDirectories(rootPath: string): Promise<string[]> {
183+
private async findI18nDirectories(
184+
rootPath: string,
185+
fsLimit: ReturnType<typeof pLimit>,
186+
): Promise<string[]> {
184187
const entries = await fs
185188
.readdir(rootPath, { withFileTypes: true })
186189
.catch(() => null);
187190
if (!entries) {
188191
return [];
189192
}
190-
const fsLimit = pLimit(8);
191193
const nestedResults = await Promise.all(
192194
entries
193195
.filter((entry) => entry.isDirectory())
@@ -198,7 +200,7 @@ export class ExtensionJsonLoader extends I18nLoader implements OnModuleDestroy {
198200
return [entryPath];
199201
}
200202

201-
return this.findI18nDirectories(entryPath);
203+
return this.findI18nDirectories(entryPath, fsLimit);
202204
}),
203205
),
204206
);

0 commit comments

Comments
 (0)