Skip to content

Commit

Permalink
fix(gatsby): Only start write page-data.json activity if there's page…
Browse files Browse the repository at this point in the history
…s to write (#34403)
  • Loading branch information
KyleAMathews committed Jan 5, 2022
1 parent f4f1313 commit ca37398
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/gatsby/src/utils/page-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,7 @@ export async function flush(parentSpan?: Span): Promise<void> {
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

Expand All @@ -181,6 +175,14 @@ export async function flush(parentSpan?: Span): Promise<void> {
// 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) => {
Expand Down Expand Up @@ -268,8 +270,9 @@ export async function flush(parentSpan?: Span): Promise<void> {
flushQueue.drain = resolve as () => unknown
})
}

writePageDataActivity.end()
if (writePageDataActivity) {
writePageDataActivity.end()
}

isFlushing = false

Expand Down

0 comments on commit ca37398

Please sign in to comment.