From 882e09ca0b7dc36866c7f63bb64bd50dd17c0128 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Wed, 5 Jan 2022 11:21:11 -0800 Subject: [PATCH 1/2] fix(gatsby): Only start write page-data.json activity if there's pages to write Make logs a bit less noisy --- packages/gatsby/src/utils/page-data.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/gatsby/src/utils/page-data.ts b/packages/gatsby/src/utils/page-data.ts index 37e185a3c4127..2b81fcbe4315a 100644 --- a/packages/gatsby/src/utils/page-data.ts +++ b/packages/gatsby/src/utils/page-data.ts @@ -166,13 +166,7 @@ export async function flush(parentSpan?: Span): Promise { const isBuild = program?._?.[0] !== `develop` const { pagePaths } = pendingPageDataWrites - const writePageDataActivity = reporter.createProgress( - `Writing page-data.json files to public directory`, - pagePaths.size, - 0, - { id: `write-page-data-public-directory`, parentSpan } - ) - writePageDataActivity.start() + let writePageDataActivity let nodeManifestPagePathMap @@ -181,6 +175,14 @@ export async function flush(parentSpan?: Span): Promise { // We use this manifestId to determine if the page data is up to date when routing. Here we create a map of "pagePath": "manifestId" while processing and writing node manifest files. // We only do this when there are pending page-data writes because otherwise we could flush pending createNodeManifest calls before page-data.json files are written. Which means those page-data files wouldn't have the corresponding manifest id's written to them. nodeManifestPagePathMap = await processNodeManifests() + + writePageDataActivity = reporter.createProgress( + `Writing page-data.json files to public directory`, + pagePaths.size, + 0, + { id: `write-page-data-public-directory`, parentSpan } + ) + writePageDataActivity.start() } const flushQueue = fastq(async (pagePath, cb) => { @@ -268,8 +270,9 @@ export async function flush(parentSpan?: Span): Promise { flushQueue.drain = resolve as () => unknown }) } - - writePageDataActivity.end() + if (writePageDataActivity) { + writePageDataActivity.end() + } isFlushing = false From 3dca85f96aead51b40409a59e6696cad004a8026 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Wed, 5 Jan 2022 12:16:22 -0800 Subject: [PATCH 2/2] Fix lint --- packages/gatsby/src/utils/page-data.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/utils/page-data.ts b/packages/gatsby/src/utils/page-data.ts index 2b81fcbe4315a..2f6c4757ee68b 100644 --- a/packages/gatsby/src/utils/page-data.ts +++ b/packages/gatsby/src/utils/page-data.ts @@ -175,7 +175,7 @@ export async function flush(parentSpan?: Span): Promise { // We use this manifestId to determine if the page data is up to date when routing. Here we create a map of "pagePath": "manifestId" while processing and writing node manifest files. // We only do this when there are pending page-data writes because otherwise we could flush pending createNodeManifest calls before page-data.json files are written. Which means those page-data files wouldn't have the corresponding manifest id's written to them. nodeManifestPagePathMap = await processNodeManifests() - + writePageDataActivity = reporter.createProgress( `Writing page-data.json files to public directory`, pagePaths.size, @@ -271,7 +271,7 @@ export async function flush(parentSpan?: Span): Promise { }) } if (writePageDataActivity) { - writePageDataActivity.end() + writePageDataActivity.end() } isFlushing = false