Skip to content

Commit 07a126d

Browse files
authored
fix(gatsby): stale node manifests (#36988)
* process stale node manifests * add condition
1 parent 288d836 commit 07a126d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/gatsby/src/utils/page-data.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ export function isFlushEnqueued(): boolean {
148148
return isFlushPending
149149
}
150150

151+
let staleNodeManifests = false
152+
const maxManifestIdsToLog = 50
153+
151154
export async function flush(parentSpan?: Span): Promise<void> {
152155
if (isFlushing) {
153156
// We're already in the middle of a flush
@@ -162,6 +165,7 @@ export async function flush(parentSpan?: Span): Promise<void> {
162165
program,
163166
staticQueriesByTemplate,
164167
queries,
168+
nodeManifests,
165169
} = store.getState()
166170
const isBuild = program?._?.[0] !== `develop`
167171

@@ -183,6 +187,25 @@ export async function flush(parentSpan?: Span): Promise<void> {
183187
{ id: `write-page-data-public-directory`, parentSpan }
184188
)
185189
writePageDataActivity.start()
190+
} else if (nodeManifests.length > 0 && staleNodeManifests) {
191+
staleNodeManifests = false
192+
193+
reporter.warn(
194+
`[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
195+
.map(n => n.manifestId)
196+
.slice(0, maxManifestIdsToLog)
197+
.join(`,`)}${
198+
nodeManifests.length > maxManifestIdsToLog
199+
? ` There were ${
200+
nodeManifests.length - maxManifestIdsToLog
201+
} additional ID's that were not logged due to output length.`
202+
: ``
203+
}`
204+
)
205+
206+
nodeManifestPagePathMap = await processNodeManifests()
207+
} else if (nodeManifests.length > 0) {
208+
staleNodeManifests = true
186209
}
187210

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

0 commit comments

Comments
 (0)