From eb8d67f6e852214e9fc6896cdfc12d6e9071023f Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Wed, 25 Aug 2021 16:22:41 -0700 Subject: [PATCH 1/4] debug --- .../source-nodes/update-nodes/wp-actions/update.js | 10 ++++++++++ 1 file changed, 10 insertions(+) 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..46f591477553c 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 @@ -39,6 +39,16 @@ export const fetchAndCreateSingleNode = async ({ return query } + dump({ + singleName, + id, + actionType, + cachedNodeIds, + token, + isPreview, + userDatabaseId, + }) + const query = getNodeQuery() const { From e8ec708b58fe3f6bdd35211196a56b32a450d285 Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Wed, 25 Aug 2021 16:38:16 -0700 Subject: [PATCH 2/4] fix draft previews --- .../update-nodes/wp-actions/update.js | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) 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 46f591477553c..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,21 +35,11 @@ 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 } - dump({ - singleName, - id, - actionType, - cachedNodeIds, - token, - isPreview, - userDatabaseId, - }) - const query = getNodeQuery() const { @@ -91,6 +82,16 @@ export const fetchAndCreateSingleNode = async ({ ) ) + reporter.info({ + singleName, + id, + actionType, + cachedNodeIds, + token, + isPreview, + userDatabaseId, + }) + return { node: null } } From cdb8a9dee8fa9b2b6fef644583dea38123723159 Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Wed, 25 Aug 2021 17:30:38 -0700 Subject: [PATCH 3/4] invoke leftover callbacks at the start of preview sourcing --- .../src/steps/preview/index.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/gatsby-source-wordpress/src/steps/preview/index.ts b/packages/gatsby-source-wordpress/src/steps/preview/index.ts index 92ed072b3eef2..5f5f2ae0c271d 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` && @@ -38,6 +39,7 @@ export type PreviewStatusUnion = | `NO_PAGE_CREATED_FOR_PREVIEWED_NODE` | `GATSBY_PREVIEW_PROCESS_ERROR` | `RECEIVED_PREVIEW_DATA_FROM_WRONG_URL` + | `FOUND_LEFTOVER_PREVIEW_CALLBACKS` export interface IPreviewData { previewDatabaseId: number @@ -367,14 +369,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: `FOUND_LEFTOVER_PREVIEW_CALLBACKS`, + context: `Starting sourcePreviews`, + }) const wpGatsbyPreviewNodeManifestsAreSupported = await remoteSchemaSupportsFieldNameOnTypeName({ From 667d6c4373d9dc0f3bd1906a98569263b7802b33 Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Wed, 25 Aug 2021 17:37:36 -0700 Subject: [PATCH 4/4] use proper status --- packages/gatsby-source-wordpress/src/steps/preview/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/gatsby-source-wordpress/src/steps/preview/index.ts b/packages/gatsby-source-wordpress/src/steps/preview/index.ts index 5f5f2ae0c271d..10128d2eaccbf 100644 --- a/packages/gatsby-source-wordpress/src/steps/preview/index.ts +++ b/packages/gatsby-source-wordpress/src/steps/preview/index.ts @@ -39,7 +39,6 @@ export type PreviewStatusUnion = | `NO_PAGE_CREATED_FOR_PREVIEWED_NODE` | `GATSBY_PREVIEW_PROCESS_ERROR` | `RECEIVED_PREVIEW_DATA_FROM_WRONG_URL` - | `FOUND_LEFTOVER_PREVIEW_CALLBACKS` export interface IPreviewData { previewDatabaseId: number @@ -371,7 +370,7 @@ export const sourcePreviews = async (helpers: GatsbyHelpers): Promise => { // in case there are preview callbacks from our last build await invokeAndCleanupLeftoverPreviewCallbacks({ - status: `FOUND_LEFTOVER_PREVIEW_CALLBACKS`, + status: `GATSBY_PREVIEW_PROCESS_ERROR`, context: `Starting sourcePreviews`, })