From 2e86aa55a06fa1026a9c0441a7187645c1a5cbb7 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Mon, 29 Jul 2024 14:04:17 -0400 Subject: [PATCH] fix: reduce number of concurrent git processes spawned Signed-off-by: Timothy Johnson --- .../docusaurus-plugin-content-docs/src/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-plugin-content-docs/src/index.ts b/packages/docusaurus-plugin-content-docs/src/index.ts index c45c520ac5d0..3c304c2c9c2b 100644 --- a/packages/docusaurus-plugin-content-docs/src/index.ts +++ b/packages/docusaurus-plugin-content-docs/src/index.ts @@ -63,6 +63,12 @@ import type {LoadContext, Plugin} from '@docusaurus/types'; import type {DocFile, FullVersion} from './types'; import type {RuleSetUseItem} from 'webpack'; +// Reduces number of concurrent Git processes spawned to get file commit date +// See https://github.com/facebook/docusaurus/issues/10348 +const Concurrency = process.env.DOCUSAURUS_GIT_CONCURRENCY + ? parseInt(process.env.DOCUSAURUS_GIT_CONCURRENCY, 10) + : 100; + // TODO this is bad, we should have a better way to do this (new lifecycle?) // The source to permalink is currently a mutable map passed to the mdx loader // for link resolution @@ -191,7 +197,15 @@ export default async function pluginContentDocs( tagsFile, }); } - return Promise.all(docFiles.map(processVersionDoc)); + const results = []; + while (docFiles.length > 0) { + results.push( + ...(await Promise.all( + docFiles.splice(0, Concurrency).map(processVersionDoc), + )), + ); + } + return results; } async function doLoadVersion(