diff --git a/packages/gatsby-source-wordpress/src/steps/preview/index.ts b/packages/gatsby-source-wordpress/src/steps/preview/index.ts index 92ed072b3eef2..10128d2eaccbf 100644 --- a/packages/gatsby-source-wordpress/src/steps/preview/index.ts +++ b/packages/gatsby-source-wordpress/src/steps/preview/index.ts @@ -19,6 +19,7 @@ import { formatLogMessage } from "~/utils/format-log-message" import { touchValidNodes } from "../source-nodes/update-nodes/fetch-node-updates" import { Reporter } from "gatsby/reporter" +import { invokeAndCleanupLeftoverPreviewCallbacks } from "./cleanup" const inDevelopPreview = process.env.NODE_ENV === `development` && @@ -367,14 +368,11 @@ export const sourcePreviews = async (helpers: GatsbyHelpers): Promise => { dump(webhookBody) } - if (previewForIdIsAlreadyBeingProcessed(webhookBody?.id)) { - if (inPreviewDebugMode) { - reporter.info( - `Preview for id ${webhookBody?.id} is already being sourced.` - ) - } - return - } + // in case there are preview callbacks from our last build + await invokeAndCleanupLeftoverPreviewCallbacks({ + status: `GATSBY_PREVIEW_PROCESS_ERROR`, + context: `Starting sourcePreviews`, + }) const wpGatsbyPreviewNodeManifestsAreSupported = await remoteSchemaSupportsFieldNameOnTypeName({ diff --git a/packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js b/packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js index a6448420aca8c..f27f1492f8649 100644 --- a/packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js +++ b/packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js @@ -24,6 +24,7 @@ export const fetchAndCreateSingleNode = async ({ cachedNodeIds, token = null, isPreview = false, + isDraft = false, userDatabaseId = null, }) => { function getNodeQuery() { @@ -34,7 +35,7 @@ export const fetchAndCreateSingleNode = async ({ // if it's a preview but it's the initial blank node // then use the regular node query as the preview query wont // return anything - const query = isPreview ? previewQuery : nodeQuery + const query = isPreview && !isDraft ? previewQuery : nodeQuery return query } @@ -81,6 +82,16 @@ export const fetchAndCreateSingleNode = async ({ ) ) + reporter.info({ + singleName, + id, + actionType, + cachedNodeIds, + token, + isPreview, + userDatabaseId, + }) + return { node: null } }