File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
packages/gatsby/src/utils Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,14 @@ function getStaleNodes(
8181 } )
8282}
8383
84+ const GatsbyManagedStatefulNodeTypes = new Set ( [
85+ // Gatsby will create and delete SitePage nodes as pages are created and deleted.
86+ // Additionally this node type is not even created at the time we delete stale nodes
87+ // so cleanup would happen too early resulting in deleting each nodes from previous run
88+ // and potentially recreating all of them on `createPages` that happens later.
89+ `SitePage` ,
90+ ] )
91+
8492/**
8593 * Find all stale nodes and delete them unless the node type has been opted out of stale node garbage collection.
8694 */
@@ -99,6 +107,11 @@ async function deleteStaleNodes(
99107 const { typeOwners, statefulSourcePlugins } = state
100108
101109 for ( const typeName of previouslyExistingNodeTypeNames ) {
110+ if ( GatsbyManagedStatefulNodeTypes . has ( typeName ) ) {
111+ // skip any stateful node types that are managed by Gatsby
112+ continue
113+ }
114+
102115 const pluginName = typeOwners . typesToPlugins . get ( typeName )
103116
104117 // no need to check this type if its owner has declared its a stateful source plugin
You can’t perform that action at this time.
0 commit comments