Skip to content

Commit

Permalink
fix(gatsby): stale node manifests (#36988)
Browse files Browse the repository at this point in the history
* process stale node manifests

* add condition
  • Loading branch information
TylerBarnes committed Nov 9, 2022
1 parent 288d836 commit 07a126d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/gatsby/src/utils/page-data.ts
Expand Up @@ -148,6 +148,9 @@ export function isFlushEnqueued(): boolean {
return isFlushPending
}

let staleNodeManifests = false
const maxManifestIdsToLog = 50

export async function flush(parentSpan?: Span): Promise<void> {
if (isFlushing) {
// We're already in the middle of a flush
Expand All @@ -162,6 +165,7 @@ export async function flush(parentSpan?: Span): Promise<void> {
program,
staticQueriesByTemplate,
queries,
nodeManifests,
} = store.getState()
const isBuild = program?._?.[0] !== `develop`

Expand All @@ -183,6 +187,25 @@ export async function flush(parentSpan?: Span): Promise<void> {
{ id: `write-page-data-public-directory`, parentSpan }
)
writePageDataActivity.start()
} else if (nodeManifests.length > 0 && staleNodeManifests) {
staleNodeManifests = false

reporter.warn(
`[gatsby] node manifests were created but no page-data.json files were written, so manifest ID's were not added to page-data.json files. This may be a bug or it may be due to a source plugin creating a node manifest for a node that did not change. Node manifest IDs: ${nodeManifests
.map(n => n.manifestId)
.slice(0, maxManifestIdsToLog)
.join(`,`)}${
nodeManifests.length > maxManifestIdsToLog
? ` There were ${
nodeManifests.length - maxManifestIdsToLog
} additional ID's that were not logged due to output length.`
: ``
}`
)

nodeManifestPagePathMap = await processNodeManifests()
} else if (nodeManifests.length > 0) {
staleNodeManifests = true
}

const flushQueue = fastq(async (pagePath, cb) => {
Expand Down

0 comments on commit 07a126d

Please sign in to comment.