Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): Only start write page-data.json activity if there's pages to write #34403

Merged
merged 2 commits into from
Jan 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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